From b2c686d402db3d4cbcf6df3669674fcf1a20f078 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 15:53:12 +0000 Subject: [PATCH 1/3] docs(skills): a line-add action sets the price; a self-tied create gets a current_user default objectstack-ui rules/actions.md: an action that inserts a child line reads the price from the source the build declares (or takes it as a required param); lookupAutofill and a stored expression do not fill it on a server-side insert. objectstack-data rules/security.md: a check over a field the request never names refuses a plain create; defaultValue 'current_user' on the tying user field fills it before check is judged. One eval case per rule; both token ratchet rows paid down by true restatement first, then pinned at the measurement. Claude-Session: https://claude.ai/code/session_01ADHkmQ2cXsNaBaNbjBDxsA Co-authored-by: Claude --- .../33978-line-price-and-self-tied-create.md | 10 +++++ scripts/check-skills-token-ratchet.mjs | 35 +++++++++++++-- .../hooks-security-seeds-datasources.json | 10 +++++ skills/objectstack-data/rules/security.md | 13 ++++-- .../evals/views-apps-actions-pages.json | 10 +++++ skills/objectstack-ui/rules/actions.md | 44 +++++++++++++++++-- 6 files changed, 110 insertions(+), 12 deletions(-) create mode 100644 .changeset/33978-line-price-and-self-tied-create.md diff --git a/.changeset/33978-line-price-and-self-tied-create.md b/.changeset/33978-line-price-and-self-tied-create.md new file mode 100644 index 00000000000..fbec3b06f9c --- /dev/null +++ b/.changeset/33978-line-price-and-self-tied-create.md @@ -0,0 +1,10 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): an action that adds a child line sets the line's price, and a create policy tied to the caller gets a `current_user` default + +Clause-②: no +Metadata-protocol: none + +`objectstack-ui` `rules/actions.md` teaches that an action inserting a line item reads the price from the source the build declares (or takes it as a required param), because `lookupAutofill` and a stored `expression` do not fill it on a server-side insert. `objectstack-data` `rules/security.md` teaches that a `check` over a field the request never names refuses a plain create, and that `defaultValue: 'current_user'` on the tying `user` field fills it before `check` is judged. One eval case each. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 488a0387be6..e31b5e466ec 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1029,8 +1029,21 @@ export const CEILINGS = new Map([ // `origin/main` the file was 15056 bytes (3764 tokens, headroom 4); the // LANDED file is 15834 bytes -> 3959 tokens, ceiling +191, pinned AT the // measurement, zero headroom. - // ceil($(wc -c < skills/objectstack-data/rules/security.md) / 4) == ceil(15834 / 4) - ['skills/objectstack-data/rules/security.md', 3959], + // 3959 -> 4041: a `check` over a field the request never names refuses a + // plain create, and the tying field's `defaultValue: 'current_user'` (a + // `user` field) fills it before `check` is judged — four lines of prose + // under the § Row-Level Security example, whose second policy becomes the + // insert-only `own_tasks` that shows it. Same standing ruling, verbatim and + // untranslated: 「A:先削重复,余额按实测提高」 (record 6513306068). PAID DOWN + // FIRST: that example's `org_isolation` policy (137 bytes) — a select-only + // policy carrying `using` alone stays shown twice in the § Membership keys + // block, `current_user.organization_id` keeps its row in the placeholder + // table, and the tenant predicate itself is the Layer 0 wall of + // § Platform-global objects. On `origin/main` the file was 15834 bytes + // (3959 tokens, headroom 0); the LANDED file is 16164 bytes -> 4041 tokens, + // ceiling +82, pinned AT the measurement, zero headroom. + // ceil($(wc -c < skills/objectstack-data/rules/security.md) / 4) == ceil(16164 / 4) + ['skills/objectstack-data/rules/security.md', 4041], // 3024 -> 3109 (2026-08-31 app-repo-principles raise, see the block above). // Severity Levels listed the three values and left the CHOICE unstated: a // block rests on a judgement a person made, so a machine-inferred signal — a @@ -1108,8 +1121,22 @@ export const CEILINGS = new Map([ // URL on a `type: 'url'` action"). The file is 9028 -> 9810 bytes -> 2453 tokens, the row's 8 // bytes of headroom absorbed, ceiling +194, pinned AT the measurement. Same ruling as the lines // above (2026-10-27, tap A): 「A:先削重复,余额按实测提高」. - // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(9810 / 4) - ['skills/objectstack-ui/rules/actions.md', 2453], + // 2453 -> 2777: an action that adds a child line sets the line's price — why a + // body inserting the parent, the product and the quantity alone stores `amount` 0 + // (`lookupAutofill` fills only the form and the grid, a stored `expression` reads only + // its own row), one type-checked example whose body reads the product's price, the + // `required` param where the persona sets prices, and the `beforeInsert` hook for lines + // written past the action. PAID DOWN FIRST by 85 bytes of true restatement in this file: + // the sentence "`locations` is an array of surfaces:" (the H2 above it names `locations`, + // the table header right below says "Surface", every example writes the array); the + // `opensInNewTab` H3's tail "— async / computed redirect" (its paragraph opens "A redirect + // URL computed after a fetch"); ", holes in either" on the `helpText` bullet (the bullet + // above it lists `description` and a param's `helpText` among the `{{ }}` copy holes). + // The file is 9807 -> 11105 bytes -> 2777 tokens, the row's 1 token of headroom absorbed, + // ceiling +324, pinned AT the measurement. Same ruling as the lines above (2026-10-27, + // tap A): 「A:先削重复,余额按实测提高」. + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11105 / 4) + ['skills/objectstack-ui/rules/actions.md', 2777], // 6090 -> 6252 (#19715, card item 4): a 5-line table of contents at the top, // anchors to the file's existing headings, nothing else changed. +162 tokens, // zero headroom to absorb any of it, ceiling +162. Maintainer ruling diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index 9bd45a12d2b..fd14e90a7f3 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -190,6 +190,16 @@ "must_contain": ["membershipKeys", "my_employee_ids", "valueField: 'id'", "employee in current_user.my_employee_ids"], "must_not_contain": ["using: 'owner_id"] } + }, + { + "id": 21, + "prompt": "In our project tracker a contractor may create a `task` only when they are its `assignee` (a person field). A contractor asks the assistant \"Add a 'Launch checklist' task to the Website relaunch\" and the create answers 403, because the request names no assignee. Author the field and the contractor permission set's policy so the plain request succeeds, without widening whom a contractor may assign.", + "expected_output": "`assignee: { type: 'user', defaultValue: 'current_user' }` on `task`, and on the contractor permission set a `rowLevelSecurity` policy with `object: 'task'`, `operation: 'insert'` and `check: 'assignee == current_user.id'`. The default fills an omitted `assignee` with the acting user before `check` is judged, so a create that names no assignee is admitted and one naming someone else is still refused. The `check` is kept as it is, not loosened or dropped.", + "files": [], + "assertions": { + "must_contain": ["type: 'user'", "defaultValue: 'current_user'", "check: 'assignee == current_user.id'"], + "must_not_contain": [] + } } ] } diff --git a/skills/objectstack-data/rules/security.md b/skills/objectstack-data/rules/security.md index b0ed14dc551..84e61f9793a 100644 --- a/skills/objectstack-data/rules/security.md +++ b/skills/objectstack-data/rules/security.md @@ -85,14 +85,19 @@ rowLevelSecurity: [ check: 'owner_id == current_user.id', }, { - name: 'org_isolation', - object: 'contact', - operation: 'select', - using: 'organization_id == current_user.organization_id', + name: 'own_tasks', // task.assignee: { type: 'user', defaultValue: 'current_user' } + object: 'task', + operation: 'insert', + check: 'assignee == current_user.id', }, ] ``` +A `check` over a field the request never names refuses a plain create ("add a +task" answers 403). Give the tying field a default the check admits: +`defaultValue: 'current_user'` fills an omitted `user` field before `check` is +judged, so `own_tasks` admits a create that names no assignee. + Predicates are **canonical CEL** (ADR-0058): `field == current_user.`, `field == 'literal'`, `field in current_user.`, comparisons (`>`/`<`/`>=`/`<=`), `&&`/`||`/`!`, and `== null` checks all lower to a pushdown filter. **No** cross-object diff --git a/skills/objectstack-ui/evals/views-apps-actions-pages.json b/skills/objectstack-ui/evals/views-apps-actions-pages.json index 0e376f30712..a57bb4dd4fa 100644 --- a/skills/objectstack-ui/evals/views-apps-actions-pages.json +++ b/skills/objectstack-ui/evals/views-apps-actions-pages.json @@ -170,6 +170,16 @@ "must_contain": ["tabPermissions", "'hidden'", "requiredPermissions", "systemPermissions"], "must_not_contain": ["hidden: true,", "hidden: true }"] } + }, + { + "id": 18, + "prompt": "Sales reps add lines to an invoice from a header button: they pick a `product` and a `quantity`. Reps can neither read nor edit a price. `invoice_line.amount` is a stored `expression` (`record.quantity * record.unit_price`), and the line's `product` lookup declares `lookupAutofill` from the product's `list_price`. Author the action.", + "expected_output": "One `defineAction` (`type: 'script'`, `objectName: 'invoice'`) whose `params` are `product` and `quantity`, each borrowed with `objectOverride: 'invoice_line'`, and whose `body` (`capabilities: ['api.read', 'api.write']`) reads `ctx.api.object('product').findOne({ where: { id: input.product } })` and inserts the line with `invoice: ctx.recordId` and `unit_price: product.list_price`. `lookupAutofill` fills only the form and the grid, and the stored expression reads only its own row, so an insert that sends no `unit_price` stores `amount` 0. The body runs trusted, so it reads the price the rep cannot. If lines are also written by the API, an import or an agent, a `beforeInsert` hook on `invoice_line` copies the price instead.", + "files": [], + "assertions": { + "must_contain": ["defineAction", "ctx.api.object('product').findOne", "unit_price: product.list_price", "api.read"], + "must_not_contain": [] + } } ] } diff --git a/skills/objectstack-ui/rules/actions.md b/skills/objectstack-ui/rules/actions.md index 6f9ae070fc2..c930254edb4 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -2,8 +2,6 @@ ## Where Actions Appear (`locations`) -`locations` is an array of surfaces: - | Value | Surface | |:-----------------|:--------| | `record_header` | Detail page header (single record) | @@ -24,7 +22,7 @@ - `preflight` — a read the param dialog shows above the params before submit: `{ read: { url }, path?, fields?, seed? }` sends one `GET` (no other `method`, no body or credentials) to a same-origin API path (one leading `/`) whose only holes are `${param.NAME}` (a declared param; re-read when it changes), `${ctx.recordId}` and `${ctx.record.FIELD}`. `path` selects the answer's sub-tree (`data`); `fields` rows are `resultDialog.fields`' `{ path, label?, format? }` (omitted: JSON). Each `seed: [{ param, path }]` entry fills a declared param, drawn read-only and submitted as shown: seeded once, no `defaultValue` / `defaultFromRow` / `carryOver`, read by no hole; mark it `required` so Confirm waits for the answer. Refused without a non-empty `params` and beside `execution: 'aggregate'`. UX, not authorization: the endpoint still checks a seeded value. - `successMessage` / `errorMessage` — toast copy on success / failure; without `successMessage` the UI shows a generic "Action completed" toast. - Copy holes are `{{ }}`: `confirmText`, `description` (`'Choose the new owner of {{ record.name }}.'`) and a param's `helpText` read `record`; `successMessage` and each `outcomeMessages` entry (`resent: 'Invitation resent to {{ result.email }}'`) read `result` (the handler's answer) and `record`; `errorMessage` takes none. A `bulkActionDefs` entry's `confirmText` reads `{{ count }}` and its params by bare name (`{{ tier }}`). In all of them `${record.name}`, `{name}`, logic in a hole and a blank sentence fail `os validate`. -- A param's `helpText`, like `description`, is a sentence or an inline locale map (`{ en: 'Why {{ record.name }} is paused', 'zh-CN': '暂停原因' }`), holes in either; the map is how a page button's inline `action` (no bundle reaches it) writes its hint per locale. +- A param's `helpText`, like `description`, is a sentence or an inline locale map (`{ en: 'Why {{ record.name }} is paused', 'zh-CN': '暂停原因' }`); the map is how a page button's inline `action` (no bundle reaches it) writes its hint per locale. - `undoable: true` — an **Undo** in the success toast (and `Ctrl+Z`). Snapshot: runtime on `operation: 'update'`, console on `type: 'api'`; else refused. @@ -142,7 +140,7 @@ export const PrintA3Action = defineAction({ }); ``` -### `opensInNewTab` + `newTabUrl` — async / computed redirect (SSO) +### `opensInNewTab` + `newTabUrl` (SSO) A redirect URL **computed after a fetch**: `opensInNewTab: true` pre-opens the tab synchronously on click (no popup blocker), then navigates @@ -182,4 +180,42 @@ that overrides `type` names its own `widget`); `objectOverride` borrows a field of another object, and `defaultFromRow: true` pre-fills from the selected row in `list_item` contexts. +**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 `amount` 0. Read +the price from the source the build declares, or take it as a `required` param +where the persona sets prices: + + +```typescript +import { defineAction } from '@objectstack/spec/ui'; + +export const AddInvoiceLineAction = defineAction({ + name: 'crm_add_invoice_line', + label: 'Add Line', + objectName: 'invoice', + type: 'script', + locations: ['record_header'], + params: [ + { field: 'product', objectOverride: 'invoice_line', required: true }, + { field: 'quantity', objectOverride: 'invoice_line', required: true }, + ], + body: { + language: 'js', + source: ` + const product = await ctx.api.object('product').findOne({ where: { id: input.product } }); + await ctx.api.object('invoice_line').insert({ + invoice: ctx.recordId, product: input.product, quantity: input.quantity, + unit_price: product.list_price, + }); + `, + capabilities: ['api.read', 'api.write'], + }, +}); +``` + +Lines also written past the action (API, import, an agent) get the price from +a `beforeInsert` hook on the line instead (objectstack-data → Lifecycle Hooks), +`runAs: 'system'` when the writer cannot read it. + > Set `refreshAfter: true` whenever the action mutates the current record. From 112baf5cd20e91e79f97a85de2b02bd75b472393 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 16:00:17 +0000 Subject: [PATCH 2/3] docs(skills): a line inserted without a price stores no amount Measured on the engine: a stored expression over an unsent unit_price persists an empty amount, so the rule text, its eval and the ratchet row say that instead of naming a zero. Claude-Session: https://claude.ai/code/session_01ADHkmQ2cXsNaBaNbjBDxsA Co-authored-by: Claude --- scripts/check-skills-token-ratchet.mjs | 6 +++--- skills/objectstack-ui/evals/views-apps-actions-pages.json | 2 +- skills/objectstack-ui/rules/actions.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index e31b5e466ec..b053baea70a 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1122,7 +1122,7 @@ export const CEILINGS = new Map([ // bytes of headroom absorbed, ceiling +194, pinned AT the measurement. Same ruling as the lines // above (2026-10-27, tap A): 「A:先削重复,余额按实测提高」. // 2453 -> 2777: an action that adds a child line sets the line's price — why a - // body inserting the parent, the product and the quantity alone stores `amount` 0 + // body inserting the parent, the product and the quantity alone stores no `amount` // (`lookupAutofill` fills only the form and the grid, a stored `expression` reads only // its own row), one type-checked example whose body reads the product's price, the // `required` param where the persona sets prices, and the `beforeInsert` hook for lines @@ -1132,10 +1132,10 @@ export const CEILINGS = new Map([ // `opensInNewTab` H3's tail "— async / computed redirect" (its paragraph opens "A redirect // URL computed after a fetch"); ", holes in either" on the `helpText` bullet (the bullet // above it lists `description` and a param's `helpText` among the `{{ }}` copy holes). - // The file is 9807 -> 11105 bytes -> 2777 tokens, the row's 1 token of headroom absorbed, + // The file is 9807 -> 11106 bytes -> 2777 tokens, the row's 1 token of headroom absorbed, // ceiling +324, pinned AT the measurement. Same ruling as the lines above (2026-10-27, // tap A): 「A:先削重复,余额按实测提高」. - // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11105 / 4) + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11106 / 4) ['skills/objectstack-ui/rules/actions.md', 2777], // 6090 -> 6252 (#19715, card item 4): a 5-line table of contents at the top, // anchors to the file's existing headings, nothing else changed. +162 tokens, diff --git a/skills/objectstack-ui/evals/views-apps-actions-pages.json b/skills/objectstack-ui/evals/views-apps-actions-pages.json index a57bb4dd4fa..c2e4276e7a4 100644 --- a/skills/objectstack-ui/evals/views-apps-actions-pages.json +++ b/skills/objectstack-ui/evals/views-apps-actions-pages.json @@ -174,7 +174,7 @@ { "id": 18, "prompt": "Sales reps add lines to an invoice from a header button: they pick a `product` and a `quantity`. Reps can neither read nor edit a price. `invoice_line.amount` is a stored `expression` (`record.quantity * record.unit_price`), and the line's `product` lookup declares `lookupAutofill` from the product's `list_price`. Author the action.", - "expected_output": "One `defineAction` (`type: 'script'`, `objectName: 'invoice'`) whose `params` are `product` and `quantity`, each borrowed with `objectOverride: 'invoice_line'`, and whose `body` (`capabilities: ['api.read', 'api.write']`) reads `ctx.api.object('product').findOne({ where: { id: input.product } })` and inserts the line with `invoice: ctx.recordId` and `unit_price: product.list_price`. `lookupAutofill` fills only the form and the grid, and the stored expression reads only its own row, so an insert that sends no `unit_price` stores `amount` 0. The body runs trusted, so it reads the price the rep cannot. If lines are also written by the API, an import or an agent, a `beforeInsert` hook on `invoice_line` copies the price instead.", + "expected_output": "One `defineAction` (`type: 'script'`, `objectName: 'invoice'`) whose `params` are `product` and `quantity`, each borrowed with `objectOverride: 'invoice_line'`, and whose `body` (`capabilities: ['api.read', 'api.write']`) reads `ctx.api.object('product').findOne({ where: { id: input.product } })` and inserts the line with `invoice: ctx.recordId` and `unit_price: product.list_price`. `lookupAutofill` fills only the form and the grid, and the stored expression reads only its own row, so an insert that sends no `unit_price` stores no `amount`. The body runs trusted, so it reads the price the rep cannot. If lines are also written by the API, an import or an agent, a `beforeInsert` hook on `invoice_line` copies the price instead.", "files": [], "assertions": { "must_contain": ["defineAction", "ctx.api.object('product').findOne", "unit_price: product.list_price", "api.read"], diff --git a/skills/objectstack-ui/rules/actions.md b/skills/objectstack-ui/rules/actions.md index c930254edb4..a6f1010205a 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -182,7 +182,7 @@ pre-fills from the selected row in `list_item` contexts. **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 `amount` 0. Read +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: From 0d221b0ccdcb97e6e9e4ef46bc904978978ad189 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 17:01:51 +0000 Subject: [PATCH 3/3] docs(skills): the add-line example refreshes and guards the product; the grid rule names its scope The Add Line action sets refreshAfter and refuses a product it cannot find; the hook sentence says an import with automations off skips hooks; SKILL.md's line-item grid paragraph says its no-button rule is about the grid and points a record-header insert at rules/actions.md. Both ratchet rows re-pinned at the measurement. Claude-Session: https://claude.ai/code/session_01ADHkmQ2cXsNaBaNbjBDxsA Co-authored-by: Claude --- scripts/check-skills-token-ratchet.mjs | 22 ++++++++++++++++++---- skills/objectstack-ui/SKILL.md | 5 +++-- skills/objectstack-ui/rules/actions.md | 9 ++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 0184d58b53b..7a3947c2f32 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -814,8 +814,16 @@ export const CEILINGS = new Map([ // measurement, zero headroom. Authority: the ruling of record that orders this text into // the published skills, objectstack-ai/cloud#3659 letter A (ruling comment 6682024726), via // the standing 2026-10-27 ruling (record 6513306068), quoted verbatim in the PR body. - // ceil(($(wc -c < skills/objectstack-ui/SKILL.md) - 20) / 4) == ceil(15256 / 4) - ['skills/objectstack-ui/SKILL.md', 3814], + // 3814 -> 3833: one clause in the line-item grid paragraph — "never add an 'Add line' + // button" is about the grid, and a record-header action that inserts a priced line is + // `rules/actions.md` — so the paragraph does not read as forbidding the action that file + // teaches. No passage of this file restates it or was found restating another, so nothing + // is cut first; the standing ruling's second half carries the raise, verbatim and + // untranslated: 「A:先削重复,余额按实测提高」 (record 6513306068). The file was 15253 + // bytes (15233 priced, 3809 tokens, headroom 5) -> 15349 (15329 priced) -> 3833 tokens, + // the 5 absorbed, ceiling +19, pinned AT the measurement, zero headroom. + // ceil(($(wc -c < skills/objectstack-ui/SKILL.md) - 20) / 4) == ceil(15329 / 4) + ['skills/objectstack-ui/SKILL.md', 3833], // 8333 -> 6193: RE-LOCK at the landed count after the #19715 split (decision // batch #213 item 1, maintainer 「1 2 4 同意」): the worked R1, the report // template and the v17-canonical shapes block moved VERBATIM into @@ -1151,8 +1159,14 @@ export const CEILINGS = new Map([ // The file is 9807 -> 11106 bytes -> 2777 tokens, the row's 1 token of headroom absorbed, // ceiling +324, pinned AT the measurement. Same ruling as the lines above (2026-10-27, // tap A): 「A:先削重复,余额按实测提高」. - // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11106 / 4) - ['skills/objectstack-ui/rules/actions.md', 2777], + // 2777 -> 2808: that example gains `refreshAfter: true` (the line moves the invoice's + // roll-up) and a guard for a product `findOne` does not return, and the closing sentence + // says an import with automations off skips the hook. Nothing further in the file restates + // another passage (the 85 bytes above were what there was), so the same ruling's second + // half carries it: the file is 11106 -> 11231 bytes -> 2808 tokens, zero headroom before, + // ceiling +31, pinned AT the measurement. + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11231 / 4) + ['skills/objectstack-ui/rules/actions.md', 2808], // 6090 -> 6252 (#19715, card item 4): a 5-line table of contents at the top, // anchors to the file's existing headings, nothing else changed. +162 tokens, // zero headroom to absorb any of it, ceiling +162. Maintainer ruling diff --git a/skills/objectstack-ui/SKILL.md b/skills/objectstack-ui/SKILL.md index ce01c0cd32e..55437751b87 100644 --- a/skills/objectstack-ui/SKILL.md +++ b/skills/objectstack-ui/SKILL.md @@ -101,8 +101,9 @@ every behaviour is derived from the DATA MODEL — computed columns, catalog typeahead auto-fill, persisted drag-reorder, and the live Subtotal → Tax → Total stack: **objectstack-data → Relationships → Inline Editing**. Three things are authored on this side: a trailing **ghost** row always exists, so never add an -"Add line" button (typing in the ghost materialises a row; an untouched one is -never persisted); `autofill: false` opts one column out of the typeahead copy; +"Add line" button to the grid (typing in the ghost materialises a row; an +untouched one is never persisted; a record-header action that inserts a priced +line is [Actions](./rules/actions.md)); `autofill: false` opts one column out of the typeahead copy; and the form's `taxRateField` overrides which parent field drives the totals. **Read side — the record page.** Child relationships are related lists on the diff --git a/skills/objectstack-ui/rules/actions.md b/skills/objectstack-ui/rules/actions.md index a6f1010205a..e4020ec62ec 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -204,6 +204,7 @@ export const AddInvoiceLineAction = defineAction({ language: 'js', source: ` const product = await ctx.api.object('product').findOne({ where: { id: input.product } }); + if (!product) throw new Error('Product not found.'); await ctx.api.object('invoice_line').insert({ invoice: ctx.recordId, product: input.product, quantity: input.quantity, unit_price: product.list_price, @@ -211,11 +212,13 @@ export const AddInvoiceLineAction = defineAction({ `, capabilities: ['api.read', 'api.write'], }, + refreshAfter: true, }); ``` -Lines also written past the action (API, import, an agent) get the price from -a `beforeInsert` hook on the line instead (objectstack-data → Lifecycle Hooks), -`runAs: 'system'` when the writer cannot read it. +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 instead (objectstack-data → Lifecycle Hooks), `runAs: 'system'` when the +writer cannot read it. > Set `refreshAfter: true` whenever the action mutates the current record.