From 240be1bb25964ec53db2ed326d818a52fe56308d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 00:08:56 +0000 Subject: [PATCH 1/7] docs(spec): a module doc block on action.zod.ts; the no-body arm's jsdoc says what the check judges Comment-only: no schema, export or behaviour change. Generated artifacts follow in the next commit. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- packages/spec/src/data/hook-refusal-codes.ts | 13 +++++++------ packages/spec/src/ui/action.zod.ts | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/spec/src/data/hook-refusal-codes.ts b/packages/spec/src/data/hook-refusal-codes.ts index 2159752116c..6ce0e77b42d 100644 --- a/packages/spec/src/data/hook-refusal-codes.ts +++ b/packages/spec/src/data/hook-refusal-codes.ts @@ -540,12 +540,13 @@ export function undeclaredActionRefusalReasonAtRun( } /** - * The save-time refusal for a catalogue on an action whose code cannot throw a - * code: a type other than `script` (its `target` is a URL, page, flow or - * endpoint — a refused flow answers through its own `end` refusal), an - * `expression` body, or a `script` action with neither a body nor an inline - * `target` function. `os i18n` would demand its translations and nothing would - * serve them. + * The save-time refusal for a catalogue on an action that runs no sandboxed + * `js` body, so nothing it runs can throw a declared code: a type other than + * `script` (its `target` is a URL, page, flow or endpoint — a refused flow + * answers through its own `end` refusal), an `expression` body, or a `script` + * action with no `body` — which is what a string `target` naming a host + * handler, or an inline `target` function `os build` could not lower, leaves. + * `os i18n` would demand its translations and nothing would serve them. */ export function actionRefusalsWithoutSandboxedBody(type: string, language: string | undefined): string { const has = type !== 'script' diff --git a/packages/spec/src/ui/action.zod.ts b/packages/spec/src/ui/action.zod.ts index 64d28c68b9c..41d8590bc60 100644 --- a/packages/spec/src/ui/action.zod.ts +++ b/packages/spec/src/ui/action.zod.ts @@ -1,5 +1,22 @@ // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. +/** + * Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from. + * + * An action is a command a user or an AI agent runs: a button on a record + * header, a list row or a list toolbar, or on a page. Its `type` names the + * dispatch route — a `script` body or handler, a `url`, a `flow`, an `api` + * endpoint, a `modal` or a `form` — and `locations` names the surfaces that + * draw it. Declare one with `defineAction`. + * + * Beside {@link ActionSchema}: {@link ActionParamSchema} (one input of the + * param dialog), {@link ActionLocationSchema} (the surfaces), + * {@link ActionAiSchema} (how an agent is offered the action), + * {@link ActionRefusalSchema} (one entry of the `refusals` catalogue a + * `script` body refuses through) and {@link InlineActionSchema} (an action + * declared inline on a page element instead of registered by name). + */ + import { z } from 'zod'; import { retiredKey } from '../shared/retired-key'; import { FieldType } from '../data/field.zod'; From b611b88ad00b8bc58177b4174dc820f32185b1de Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 00:17:28 +0000 Subject: [PATCH 2/7] chore(spec): regenerate the action reference page and the two skill index rows Output of check:generated --fix (gen:skill-refs, gen:docs) for the module doc block on action.zod.ts. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- content/docs/references/ui/action.mdx | 17 ++++++++++++++++- skills/objectstack-data/references/_index.md | 2 +- skills/objectstack-ui/references/_index.md | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/content/docs/references/ui/action.mdx b/content/docs/references/ui/action.mdx index dec614aeb08..ce3f182b995 100644 --- a/content/docs/references/ui/action.mdx +++ b/content/docs/references/ui/action.mdx @@ -1,11 +1,26 @@ --- title: Action schema — UI Protocol property reference navTitle: Action -description: "Action schemas of the ObjectStack UI Protocol: Action, ActionAi, ActionLocation and 4 more — each property with its type, default and a TypeScript example." +description: "Action protocol schemas — ActionSchema, the action metadata type, and the parts it is built from." --- {/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */} +Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from. + +An action is a command a user or an AI agent runs: a button on a record +header, a list row or a list toolbar, or on a page. Its `type` names the +dispatch route — a `script` body or handler, a `url`, a `flow`, an `api` +endpoint, a `modal` or a `form` — and `locations` names the surfaces that +draw it. Declare one with `defineAction`. + +Beside `ActionSchema`: `ActionParamSchema` (one input of the +param dialog), `ActionLocationSchema` (the surfaces), +`ActionAiSchema` (how an agent is offered the action), +`ActionRefusalSchema` (one entry of the `refusals` catalogue a +`script` body refuses through) and `InlineActionSchema` (an action +declared inline on a page element instead of registered by name). + **Source:** `packages/spec/src/ui/action.zod.ts` diff --git a/skills/objectstack-data/references/_index.md b/skills/objectstack-data/references/_index.md index 70456ad9993..ec47ecb6743 100644 --- a/skills/objectstack-data/references/_index.md +++ b/skills/objectstack-data/references/_index.md @@ -59,7 +59,7 @@ from `node_modules` — there is no local copy in the skill bundle. - `node_modules/@objectstack/spec/src/system/deploy-bundle.zod.ts` — Deploy Bundle Protocol - `node_modules/@objectstack/spec/src/system/translation.zod.ts` — Exports: LocaleSchema, FieldTranslationSchema, ActionResultDialogTranslationSchema, ObjectTranslationDataSchema, TranslationDataSchema - `node_modules/@objectstack/spec/src/ui/action-params.zod.ts` — The action DISPATCH contract: what the platform validates on the way in, and -- `node_modules/@objectstack/spec/src/ui/action.zod.ts` — Exports: ActionParamSchema, ActionType, ActionLocationSchema, ActionAiSchema, ActionRefusalSchema +- `node_modules/@objectstack/spec/src/ui/action.zod.ts` — Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from. - `node_modules/@objectstack/spec/src/ui/bulk-action.zod.ts` — Bulk Action Schemas - `node_modules/@objectstack/spec/src/ui/chart.zod.ts` — Unified Chart Type Taxonomy - `node_modules/@objectstack/spec/src/ui/i18n.zod.ts` — Display-label and ARIA-label primitives shared by every `ui/` shape. diff --git a/skills/objectstack-ui/references/_index.md b/skills/objectstack-ui/references/_index.md index 4b1612be625..625b677159c 100644 --- a/skills/objectstack-ui/references/_index.md +++ b/skills/objectstack-ui/references/_index.md @@ -9,7 +9,7 @@ from `node_modules` — there is no local copy in the skill bundle. ## Core schemas -- `node_modules/@objectstack/spec/src/ui/action.zod.ts` — Exports: ActionParamSchema, ActionType, ActionLocationSchema, ActionAiSchema, ActionRefusalSchema +- `node_modules/@objectstack/spec/src/ui/action.zod.ts` — Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from. - `node_modules/@objectstack/spec/src/ui/app.zod.ts` — Exports: ObjectNavItemSchema, DashboardNavItemSchema, PageNavItemSchema, UrlNavItemSchema, ReportNavItemSchema - `node_modules/@objectstack/spec/src/ui/chart.zod.ts` — Unified Chart Type Taxonomy - `node_modules/@objectstack/spec/src/ui/component.zod.ts` — Exports: PageContainerProps, PageHeaderProps, PageTabsProps, PageCardProps, RecordDetailsProps From b0b825b2665d44990cef9623e0ac0970ca0385b6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 00:23:24 +0000 Subject: [PATCH 3/7] docs(skills): the ui and i18n skills teach an action's refusals catalogue and its translation keys rules/actions.md gains the refusals section and its Add Line example throws a declared code; the i18n skill lists the action refusal keys and names an action's refusal beside a hook's; one eval case in each skill's eval file. The actions.md token row moves by the measured remainder. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- .changeset/34824-action-refusals-skill.md | 15 +++++++++++++++ scripts/check-skills-token-ratchet.mjs | 14 ++++++++++++-- skills/objectstack-i18n/SKILL.md | 9 +++++---- .../evals/bundles-locales-coverage.json | 10 ++++++++++ .../evals/views-apps-actions-pages.json | 10 ++++++++++ skills/objectstack-ui/rules/actions.md | 13 ++++++++++++- 6 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 .changeset/34824-action-refusals-skill.md diff --git a/.changeset/34824-action-refusals-skill.md b/.changeset/34824-action-refusals-skill.md new file mode 100644 index 00000000000..2115a303e51 --- /dev/null +++ b/.changeset/34824-action-refusals-skill.md @@ -0,0 +1,15 @@ +--- +'@objectstack/skills': patch +'@objectstack/spec': patch +--- + +docs(skills, spec): the ui and i18n skills teach an action's `refusals` catalogue and its translation keys; `action.zod.ts` gains a module description + +Clause-②: no — skill teaching text, evals and two comment-only edits in packages/spec; no schema, export or accept set moves +Metadata-protocol: none — no metadata key is touched + +objectstack-ui's `rules/actions.md` gains a short section, "Refusing by code (`refusals`)": a `type: 'script'` action with a `js` body declares the refusals it may throw and throws the code instead of a sentence, the catalogue, the throws and the checks are the ones a hook has (taught in objectstack-data's `references/data-hooks.md` § Declared refusals), the sentence is answered as `userMessage` and translated at `objects.._actions..refusals..message`, and an authored `errorMessage` replaces it in the console's failure toast. The file's Add Line example now declares `refusals: { PRODUCT_NOT_FOUND: … }` and throws `{ code: 'PRODUCT_NOT_FOUND' }` where it threw `new Error('Product not found.')`. + +objectstack-i18n's SKILL.md lists the keys in the object key table — `_actions.{action_name}.refusals.{CODE}` holds `message` and `reasons.{reason}.message`, the same under `globalActions.{action_name}`, and a key for a code or reason the action does not declare is `translation-target-unknown` — and the server-composed text section names an action's refusal beside a hook's. Each skill's eval file gains one case that grades the rule. + +`@objectstack/spec`: comments only. `src/ui/action.zod.ts` opens with a module doc block, so the generated reference page and the two skill reference indexes describe the module ("Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from.") where they listed its first five exports, and the jsdoc above `actionRefusalsWithoutSandboxedBody` names the third case as the function judges it: a `script` action with no `body`. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 0d7cc4e5f80..560f3042f49 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1313,8 +1313,18 @@ export const CEILINGS = new Map([ // 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], + // 2808 -> 2988: an action body refuses by code. One paragraph under the `ctx` section (which + // action may declare `refusals`; that the catalogue, the throws and the checks are a hook's, + // taught in objectstack-data and only pointed at here; the bundle key the sentence is translated + // at; that an authored `errorMessage` replaces the sentence in the console's toast), and the + // Add Line example declares one entry and throws its code where it threw a sentence. NOTHING + // TO PAY DOWN in this file: the entry above spent its last restatement and a re-read for this + // change found none, so the same ruling's second half carries it, as it did there. The file is + // 11231 -> 11952 bytes -> 2988 tokens, zero headroom before, ceiling +180, pinned AT the + // measurement. Same ruling as the lines above (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 + // (ruling record 6513306068). + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11952 / 4) + ['skills/objectstack-ui/rules/actions.md', 2988], // 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-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index 351380d4493..3b27ae52b07 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -168,6 +168,7 @@ All translatable content for a single object is aggregated under | `_sections.{section_name}` | Form section `label`, `description`; `fields.{field_name}` — the `label`, `placeholder`, `helpText` an entry overrides for that form alone (`helpText` here, `help` under `fields.{field_name}` above: each spells what its source does) | | `_tabs.{tab_name}` | Filter-preset tab `label` (`ViewTabSchema.name`) | | `_validations.{rule_name}` | `message` only — the sentence a rejected write returns (replaces the retired `validationMessages`) | +| `_actions.{action_name}.refusals.{CODE}` | `message`, and `reasons.{reason}.message` per declared reason — the sentences of the action's `refusals` catalogue (**objectstack-ui** → Actions), for a code and reason it declares (any other is `translation-target-unknown`); the same under `globalActions.{action_name}` | Top-level groups alongside `objects`: `apps` (label, description, navigation), `messages`, `globalActions` (actions with no `objectName` — a key naming a bound action is @@ -342,9 +343,8 @@ The spec models coverage results for tooling — the return shapes of the option (totals, `coveragePercent`, per-group `breakdown`) and `TranslationDiffItem` — `key` (dot path), `status` (`missing | redundant | stale`), `locale`, optional `objectName`, optional `sourceHash` for stale detection, and AI-enrichment -fields (`aiSuggested`, `aiConfidence`). Full Zod shape: -`node_modules/@objectstack/spec/src/system/translation.zod.ts` — -`TranslationCoverageResultSchema`, `TranslationDiffItemSchema`. +fields (`aiSuggested`, `aiConfidence`). Full Zod shape: `TranslationCoverageResultSchema`, +`TranslationDiffItemSchema` (`translation.zod.ts`). --- @@ -406,7 +406,8 @@ produced; a client renders it as received. code is never handed Simplified text. - **App-authored** refusal text is not on this ladder: a hook's catalogued refusal is served through `hooks..refusals..message` (a declared reason's through - `hooks..refusals..reasons..message`) in the caller's locale, negotiated over + `…..reasons..message`), an action's through its `_actions.{action_name}.refusals` + keys (table above), each in the caller's locale, negotiated over whatever locales the app's translations hold, and otherwise as declared, in the app's own source language. No `en` floor is supplied for it. Under an entry declaring `params`, a translation keeps its `{{ name }}` holes; the runtime fills them after picking it. diff --git a/skills/objectstack-i18n/evals/bundles-locales-coverage.json b/skills/objectstack-i18n/evals/bundles-locales-coverage.json index 791598e882e..45c26010aa1 100644 --- a/skills/objectstack-i18n/evals/bundles-locales-coverage.json +++ b/skills/objectstack-i18n/evals/bundles-locales-coverage.json @@ -91,6 +91,16 @@ "must_not_contain": ["pages.crm_manual", "sections.getting_started"] } }, + { + "id": 13, + "prompt": "The `submit_signoff` action on `crm_invoice` declares `refusals: { NOT_DRAFT: { message: 'Only a draft invoice can be signed off.', status: 409 }, STAGE_LOCKED: { message: 'This stage change is not allowed.', params: ['stage'], reasons: { closed: { message: 'A {{ stage }} invoice can no longer change.' } } } }`, and its body throws those codes. zh-CN users still read the English sentences. Which bundle keys translate them, and what does a caller get in a locale no bundle covers?", + "expected_output": "`objects.crm_invoice._actions.submit_signoff.refusals.NOT_DRAFT.message` and `….refusals.STAGE_LOCKED.message`, and the reason's sentence at `objects.crm_invoice._actions.submit_signoff.refusals.STAGE_LOCKED.reasons.closed.message`; an action with no `objectName` takes the same keys under `globalActions.submit_signoff`. The reason's translation keeps its `{{ stage }}` hole, which the server fills after picking the translation. The server answers the sentence in the caller's locale, negotiated over the locales the app's bundles hold, on the refusal's `userMessage`; a locale no bundle covers gets the declared sentence as written, with no `en` floor. A key for a code or reason the action does not declare is `translation-target-unknown`. Not a hook's refusal key, and not a `messages` entry the body looks up itself.", + "files": [], + "assertions": { + "must_contain": ["_actions", "submit_signoff", "refusals", "NOT_DRAFT", "reasons", "closed"], + "must_not_contain": ["hooks.submit_signoff"] + } + }, { "id": 10, "prompt": "In zh-CN the `crm_renew` action on `crm_opportunity` opens its param dialog with the rows of its pre-submit read still in English. Its `preflight.fields` declares the paths `amount` and `verdict.summary`.", diff --git a/skills/objectstack-ui/evals/views-apps-actions-pages.json b/skills/objectstack-ui/evals/views-apps-actions-pages.json index f287b10c568..f6cbd23bf6f 100644 --- a/skills/objectstack-ui/evals/views-apps-actions-pages.json +++ b/skills/objectstack-ui/evals/views-apps-actions-pages.json @@ -190,6 +190,16 @@ "must_contain": ["type: 'simple'", "modalSize"], "must_not_contain": ["type: 'tabbed'"] } + }, + { + "id": 20, + "prompt": "The `submit_signoff` script action on `crm_invoice` refuses a non-draft invoice with `throw new Error('Only a draft invoice can be signed off.')` in its `js` body, so zh-CN users read that English sentence in the failure toast. Make it refuse in the caller's language, with the code `NOT_DRAFT` and a 409.", + "expected_output": "The action declares `refusals: { NOT_DRAFT: { message: 'Only a draft invoice can be signed off.', status: 409 } }` and the body throws the code instead of the sentence: `throw { code: 'NOT_DRAFT' }`. The server answers the declared sentence on the refusal's `userMessage` with status 409, in the caller's locale once the zh-CN bundle carries `objects.crm_invoice._actions.submit_signoff.refusals.NOT_DRAFT.message`, else as declared, and the console's failure toast shows it. The action authors no failure copy of its own, which would replace that sentence in the toast. A code the body throws literally and `refusals` does not declare is refused at save. Not a locale branch in the body, and not a second sentence per language in the throw.", + "files": [], + "assertions": { + "must_contain": ["refusals", "NOT_DRAFT", "409", "_actions"], + "must_not_contain": ["hooks.submit_signoff"] + } } ] } diff --git a/skills/objectstack-ui/rules/actions.md b/skills/objectstack-ui/rules/actions.md index e4020ec62ec..6b93b347fd0 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -118,6 +118,16 @@ Bodies execute **trusted** (`ctx.api` / `ctx.engine` bypass RLS/FLS). `ctx.session.positions` (absent when the caller holds none) is **not an authorization input** — ask the security service for privilege (ADR-0095). +### Refusing by code (`refusals`) + +`throw new Error('…')` answers every caller in the author's language. A `type: 'script'` action +with a `js` body (an inline `target` function is lowered to one; any other action is refused the +key) declares `refusals` and throws the code, as `crm_add_invoice_line` below does: the catalogue, +throws and checks are a hook's (objectstack-data → Lifecycle Hooks → Declared refusals). The +sentence is answered as `userMessage`, translated at +`objects.._actions..refusals..message` (objectstack-i18n); the console's +failure toast shows it unless the action authors `errorMessage`. + ## Opening in a New Tab ### `openIn: 'new-tab'` @@ -200,11 +210,12 @@ export const AddInvoiceLineAction = defineAction({ { field: 'product', objectOverride: 'invoice_line', required: true }, { field: 'quantity', objectOverride: 'invoice_line', required: true }, ], + refusals: { PRODUCT_NOT_FOUND: { message: 'Product not found.', status: 404 } }, body: { language: 'js', source: ` const product = await ctx.api.object('product').findOne({ where: { id: input.product } }); - if (!product) throw new Error('Product not found.'); + if (!product) throw { code: 'PRODUCT_NOT_FOUND' }; await ctx.api.object('invoice_line').insert({ invoice: ctx.recordId, product: input.product, quantity: input.quantity, unit_price: product.list_price, From 2a2e7d66609a4516c7aa3dabb55576f47a42e932 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 01:01:23 +0000 Subject: [PATCH 4/7] docs(skills): actions.md pays 26 bytes of restatement before its token row moves The label line above the Add to Campaign example restated the block's own type; the row moves by the measured remainder (2808 -> 2982). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- scripts/check-skills-token-ratchet.mjs | 20 +++++++++++--------- skills/objectstack-ui/rules/actions.md | 2 -- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 560f3042f49..b741b945ebf 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1313,18 +1313,20 @@ export const CEILINGS = new Map([ // 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. - // 2808 -> 2988: an action body refuses by code. One paragraph under the `ctx` section (which + // 2808 -> 2982: an action body refuses by code. One paragraph under the `ctx` section (which // action may declare `refusals`; that the catalogue, the throws and the checks are a hook's, // taught in objectstack-data and only pointed at here; the bundle key the sentence is translated // at; that an authored `errorMessage` replaces the sentence in the console's toast), and the - // Add Line example declares one entry and throws its code where it threw a sentence. NOTHING - // TO PAY DOWN in this file: the entry above spent its last restatement and a re-read for this - // change found none, so the same ruling's second half carries it, as it did there. The file is - // 11231 -> 11952 bytes -> 2988 tokens, zero headroom before, ceiling +180, pinned AT the - // measurement. Same ruling as the lines above (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 - // (ruling record 6513306068). - // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11952 / 4) - ['skills/objectstack-ui/rules/actions.md', 2988], + // Add Line example declares one entry and throws its code where it threw a sentence. PAID DOWN + // FIRST by 26 bytes of true restatement in this file: the label line "**Script-typed action**:" + // above the Add to Campaign example (the block's own `type: 'script'` says it, under the H2 + // "Examples"). Two reads of the file found no other passage restating another, so the same + // ruling's second half carries the rest. Arithmetic: the text adds 721 bytes, the cut removes + // 26, so the file is 11231 -> 11926 bytes -> 2982 tokens, zero headroom before, ceiling +174, + // the measured remainder only, pinned AT the measurement. Same ruling as the lines above + // (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 (ruling record 6513306068). + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11926 / 4) + ['skills/objectstack-ui/rules/actions.md', 2982], // 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/rules/actions.md b/skills/objectstack-ui/rules/actions.md index 6b93b347fd0..9e59599e13d 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -72,8 +72,6 @@ export const ConvertLeadAction = defineAction({ }); ``` -**Script-typed action**: - ```typescript import { defineAction } from '@objectstack/spec/ui'; From 85b26c86d48ca8fbb2ec66689ded99e499ead6a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 02:31:02 +0000 Subject: [PATCH 5/7] docs(skills): cut restatement in rules/actions.md and the i18n SKILL.md; the actions.md token row moves 2982 to 2957 rules/actions.md: four more same-file restatements cut (98 bytes), each with its surviving home named in the ratchet row's comment. The file is 11828 bytes, 2957 tokens; the row follows the measurement down, so the raise from 2808 is +149 where it was +174. objectstack-i18n/SKILL.md: the Shipped examples lines no longer repeat the file names the File Organization table lists (63 bytes). The row stays 6333; merged with origin/main the file measures 6327 tokens. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- scripts/check-skills-token-ratchet.mjs | 26 +++++++++++++++++--------- skills/objectstack-i18n/SKILL.md | 4 ++-- skills/objectstack-ui/rules/actions.md | 14 +++++++------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index e8e1a262796..f954f509537 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1328,20 +1328,28 @@ export const CEILINGS = new Map([ // 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. - // 2808 -> 2982: an action body refuses by code. One paragraph under the `ctx` section (which + // 2808 -> 2957: an action body refuses by code. One paragraph under the `ctx` section (which // action may declare `refusals`; that the catalogue, the throws and the checks are a hook's, // taught in objectstack-data and only pointed at here; the bundle key the sentence is translated // at; that an authored `errorMessage` replaces the sentence in the console's toast), and the // Add Line example declares one entry and throws its code where it threw a sentence. PAID DOWN - // FIRST by 26 bytes of true restatement in this file: the label line "**Script-typed action**:" - // above the Add to Campaign example (the block's own `type: 'script'` says it, under the H2 - // "Examples"). Two reads of the file found no other passage restating another, so the same - // ruling's second half carries the rest. Arithmetic: the text adds 721 bytes, the cut removes - // 26, so the file is 11231 -> 11926 bytes -> 2982 tokens, zero headroom before, ceiling +174, - // the measured remainder only, pinned AT the measurement. Same ruling as the lines above + // FIRST by 124 bytes of true restatement in this file, five cuts: the label line + // "**Script-typed action**:" above the Add to Campaign example (26; the block's own + // `type: 'script'` says it, under the H2 "Examples"); the label "**Flow-typed action**" and the + // parentheses it held the `onSuccess` note in (19 net, the note now says "the flow run"; the + // block's own `type: 'flow'` says it); "`openIn: 'new-tab'` opens it in a new tab," (35 net, + // `'self'` now spelled `openIn: 'self'`; the H3 "`openIn: 'new-tab'`" under the H2 "Opening in + // a New Tab" and the example's `openIn: 'new-tab'` line say it); " on success / failure" on + // the `successMessage` / `errorMessage` bullet (21; the two key names, that bullet's + // "Action completed" half and the refusals paragraph's "failure toast … `errorMessage`" say + // it); "(`{ field: 'email' }`)" beside "field-backed params" (23; the `{ field: … }` params of + // the Reassign Lead, Add to Campaign and Add Line examples show the shape). The same ruling's + // second half carries the rest. Arithmetic: the text adds 721 bytes, the cuts remove 124, so + // the file is 11231 -> 11828 bytes -> 2957 tokens, zero headroom before, ceiling +149, the + // measured remainder only, pinned AT the measurement. Same ruling as the lines above // (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 (ruling record 6513306068). - // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11926 / 4) - ['skills/objectstack-ui/rules/actions.md', 2982], + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(11828 / 4) + ['skills/objectstack-ui/rules/actions.md', 2957], // 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-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index 3b27ae52b07..8cbb23b6462 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -482,8 +482,8 @@ every plugin contributes its own `objects.*` slice. ## Shipped examples -`examples/app-crm` — the bundled layout (one `crm.translation.ts`, `en` + `zh-CN`). -`examples/app-todo` — the per-locale layout (`{en,zh-CN,ja-JP}.ts` + `index.ts`). +`examples/app-crm` — the bundled layout (`en` + `zh-CN`). +`examples/app-todo` — the per-locale layout. --- diff --git a/skills/objectstack-ui/rules/actions.md b/skills/objectstack-ui/rules/actions.md index 9e59599e13d..15c109b5af7 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -20,7 +20,7 @@ - `confirmText` — set for any destructive or irreversible operation; the confirm dialog of a param-less action. A registered action is refused it beside a non-empty `params` (put the question on `description`); a view's `bulkActionDefs` entry pairs the two by its own contract. - `submitText` — the verb on the param dialog's submit button ("Send", "Log Call") in place of "Confirm": an I18nLabel, refused blank and refused without a non-empty `params` (no dialog opens); `submitLabel` / `confirmLabel` are refused naming this key. - `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. +- `successMessage` / `errorMessage` — toast copy; 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': '暂停原因' }`); 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. @@ -49,7 +49,7 @@ export const ReassignLeadAction = defineAction({ ## Examples -**Flow-typed action** (`onSuccess` hops once the run completes, not when it pauses at a screen; its URL template reads an `isOutput` variable as `${result.output.NAME}`): +`onSuccess` hops once the flow run completes, not when it pauses at a screen; its URL template reads an `isOutput` variable as `${result.output.NAME}`: ```typescript @@ -130,9 +130,9 @@ failure toast shows it unless the action authors `errorMessage`. ### `openIn: 'new-tab'` -A **static** `target` URL on a `type: 'url'` action: `openIn: 'new-tab'` opens -it in a new tab, `'self'` forces in-place navigation; omitted, absolute URLs open -in a new tab and relative ones navigate in place. +A **static** `target` URL on a `type: 'url'` action: `openIn: 'self'` forces +in-place navigation; omitted, absolute URLs open in a new tab and relative ones +navigate in place. ```typescript @@ -181,8 +181,8 @@ export const OpenInvoicePdfAction = defineAction({ ## Action Parameter Patterns -Prefer **field-backed** params (`{ field: 'email' }`): label (i18n), type, -validation, options, placeholder and widget come from the object metadata +Prefer **field-backed** params: label (i18n), type, validation, options, +placeholder and widget come from the object metadata (`widget` only while the param keeps or restates the field's `type`; a param that overrides `type` names its own `widget`); `objectOverride` borrows a field of another object, and `defaultFromRow: true` From b33d995a4958d770fd83d0adc13dc453a4b1f63b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 02:52:51 +0000 Subject: [PATCH 6/7] test(spec): ui/action.zod.ts leaves the #13334 no-description list and is pinned on its module header The #13334 corpus pin froze ui/action.zod.ts as describing nothing, because the codemod-wedged symbol comment it once opened with was removed. This PR's N4 gives that module a header written on purpose, above its imports, so the pin went red on the change it was meant to leave room for. The file leaves the list (seven remain, unchanged), and a new case pins its opening exactly, that only the licence line precedes the block, and that the import list follows it. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- .../spec/scripts/file-description.test.ts | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/spec/scripts/file-description.test.ts b/packages/spec/scripts/file-description.test.ts index 61e12aeae5d..4bf99ba91da 100644 --- a/packages/spec/scripts/file-description.test.ts +++ b/packages/spec/scripts/file-description.test.ts @@ -1796,13 +1796,17 @@ describe('corpus — no reference source donates a symbol comment to its page', expect(openingOf('shared/mapping.zod.ts')).toBe('@module shared/mapping'); }); - it('publishes no description for the eight modules whose opening was one schema\'s doc (#13334)', () => { + it('publishes no description for seven of the eight modules whose opening was one schema\'s doc (#13334)', () => { // The corpus half of route ② — each of the eight had a symbol's comment // wedged into its import list by the lazify codemod, published as the // page's opening and as the module's skill-index pointer row. The comments // moved back to the declarations they document (or to the family they // head), so no block sits in the header zone documenting nothing: the page // honestly prints no description. 宁可缺,不要错. + // + // The eighth, `ui/action.zod.ts`, has since been given a module header + // written on purpose (#34824 N4) — the case below pins it, so it leaves + // this list rather than being exempted from it. const openingOf = (rel: string) => opening(findModuleDocBlock(fs.readFileSync(path.join(SRC_DIR, rel), 'utf-8'))); for (const rel of [ @@ -1810,7 +1814,6 @@ describe('corpus — no reference source donates a symbol comment to its page', 'data/datasource.zod.ts', 'data/hook.zod.ts', 'security/permission.zod.ts', - 'ui/action.zod.ts', 'ui/app.zod.ts', 'ui/component.zod.ts', 'ui/page.zod.ts', @@ -1818,6 +1821,34 @@ describe('corpus — no reference source donates a symbol comment to its page', expect(openingOf(rel), rel).toBeNull(); } }); + + it('opens `ui/action` with the module header written above its imports (#34824 N4)', () => { + // The one #13334 module that regained a description, and how: not a + // symbol's comment back in the import list, but a block in the header zone + // — after the licence line, before the first import — that describes the + // module. Pinned on three facts so neither a re-wedged symbol comment nor a + // header glued to a declaration can pass for it. + const rel = 'ui/action.zod.ts'; + const source = fs.readFileSync(path.join(SRC_DIR, rel), 'utf-8'); + const block = findModuleDocBlock(source); + + // ① the opening, exactly — the page's first line and the skill-index row. + expect(opening(block)).toBe( + 'Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from.', + ); + + // ② the selected block is the header zone's: nothing but the licence line + // and blanks precede it, and no import does. + const at = source.indexOf(`/**${block}*/`); + expect(at).toBeGreaterThan(-1); + const before = source.slice(0, at).split('\n').filter(l => l.trim() !== ''); + expect(before).toEqual(['// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.']); + + // ③ what follows it is the import list, not a declaration it could be + // documenting. + const after = source.slice(at + `/**${block}*/`.length).split('\n').find(l => l.trim() !== ''); + expect(after).toMatch(/^import\b/); + }); }); /** From c8e51dba6efcf450bcdaec5511d41aa917d801d5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 08:01:29 +0000 Subject: [PATCH 7/7] docs(spec): regenerate references/ui/action.mdx on the merge with main check:generated --fix after the merge commit (gen:docs, the one artifact it proved stale): main's ActionText rows from #35085 plus this branch's module description for ui/action.zod.ts. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8 --- content/docs/references/ui/action.mdx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/content/docs/references/ui/action.mdx b/content/docs/references/ui/action.mdx index ce3f182b995..0d7a61d3e37 100644 --- a/content/docs/references/ui/action.mdx +++ b/content/docs/references/ui/action.mdx @@ -28,8 +28,8 @@ declared inline on a page element instead of registered by name). ## TypeScript Usage ```typescript -import { ActionSchema, ActionAiSchema, ActionLocationSchema, ActionParamSchema, ActionRefusalSchema, ActionType, InlineActionSchema } from '@objectstack/spec/ui'; -import type { Action, ActionAi, ActionLocation, ActionParam, ActionRefusal, ActionType, InlineAction } from '@objectstack/spec/ui'; +import { ActionSchema, ActionAiSchema, ActionLocationSchema, ActionParamSchema, ActionRefusalSchema, ActionTextSchema, ActionType, InlineActionSchema } from '@objectstack/spec/ui'; +import type { Action, ActionAi, ActionLocation, ActionParam, ActionRefusal, ActionText, ActionType, InlineAction } from '@objectstack/spec/ui'; // Validate data const result = ActionSchema.parse(data); @@ -55,6 +55,7 @@ const result = ActionSchema.parse(data); | **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). | | **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. | | **refusals** | `Record; params?: string[] }>` | optional | Refusal catalogue keyed by the SCREAMING_SNAKE code the action's js body throws: `{ message, status?, reasons?, params? }`. The body refuses by code only, optionally with a declared reason and params; the runtime answers with the declared message (translated through objects.``._actions.``.refusals.``.message, or globalActions.``.refusals.``.message for an object-less action, ….reasons.``.message for a reason, in the caller's locale, holes filled from params) and status. A code not declared here, or a reason a code with reasons does not declare, is refused loudly — at save when the body throws it literally, otherwise at run time. Only a type: 'script' action with a js body declares one | +| **texts** | `Record` | optional | Texts the action's js body writes into records, keyed by the snake_case key it asks for with ctx.text(KEY, params): `{ message, params? }`. ctx.text answers the sentence in the organization's language (the Localization setting when somebody set it, else the app's i18n.defaultLocale), translated through objects.``._actions.``.texts.``.message (globalActions.``.texts.``.message for an object-less action) with the declared message as the fallback, its holes filled from params. A key not declared here is refused — at save when the body asks for it literally, otherwise at run time. Only a type: 'script' action with a js body declares one | | **operation** | `Enum<'update'>` | optional | The declarative single-record field write, mirroring a list view's `bulkActionDefs`: `'update'` applies `patch` (merged under the collected `params`) to the current record on the data plane AS THE CALLER — never system-elevated — so the caller's permissions, the object's hooks and its validations fire as for a user edit. `type` stays at its default `'script'` (the platform action route the write is performed on); `target`/`body`/`method`/`bodyExtra` are refused beside it. `'delete'` and `'custom'` have no row-level form. | | **patch** | `Record` | optional | For `operation: 'update'` — static field values written to the current record, merged UNDER the user-supplied `params` so a fixed value can be declared without exposing it in the dialog. Written on the data plane as the caller: object permissions, hooks and validations fire as for a user edit. Refused on an action without `operation: 'update'` (it would be silently dropped). | | **execution** | `Enum<'perRecord' \| 'aggregate'>` | optional | The bulk dispatch contract this action's BODY is written for, in `bulkActionDefs`' own vocabulary: 'perRecord' = one dispatch per selected row carrying that row's `recordId` (the view's `bulkActions: ['']` bare-string form); 'aggregate' = ONE dispatch for the whole selection carrying every id in `params._selectedIds` (a `bulkActionDefs` entry with `execution: 'aggregate'`). Optional with NO default — omit it only when the body genuinely serves both. A list view wiring a declared action under the other contract is refused by `@objectstack/lint` (`action-dispatch-contract-mismatch`). | @@ -161,6 +162,13 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities | **reasons** | `Record` | optional | Further sentences under this same code, keyed by the snake_case reason the action throws beside the code (`{ code, reason }`): `{ message }`. The wire code and status stay this entry's. A reason not declared here is refused loudly. Absent: the code has the one sentence, and a thrown reason is not read | | **params** | `string[]` | optional | The names this entry's sentences may fill: a `{{ NAME }}` or `{{ NAME \| formatter }}` hole renders the value the action throws in `params` (`{ code, params: { NAME: value } }`). A hole over any other name, logic, an unknown formatter, an empty hole and a currency formatter with no code are refused. Absent: the sentences are plain text and a `{{ }}` hole is refused | +### Nested Shape: `Action.texts[string]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **message** | `string` | ✅ | The sentence the action's body writes into a record — in the source locale, translated whole through objects.``._actions.``.texts.``.message (globalActions.``.texts.``.message for an object-less action) in the organization's language when the body asks for it (ctx.text). With no params every `{{ }}` hole is refused; with params a hole is a path over one of them with an optional known formatter | +| **params** | `string[]` | optional | The names this text may fill: a `{{ NAME }}` or `{{ NAME \| formatter }}` hole renders the value the action's body passes in ctx.text(KEY, `{ NAME: value }`). A hole over any other name is refused at parse; a hole holding logic, an unknown formatter, an empty hole and a currency formatter with no code are refused where the text is compiled (os validate, compile, the publish gate). Absent: the sentence is plain text and a `{{ }}` hole is refused | + ### Nested Shape: `Action.params[number]` | Property | Type | Required | Description | @@ -387,6 +395,18 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities | **message** | `string` | ✅ | The sentence the user reads when the action throws this reason under its code — in the source locale, translated through objects.``._actions.``.refusals.``.reasons.``.message (globalActions.``.… for an object-less action) in the caller's locale; its `{{ }}` holes follow the entry's message rule | +--- + +## ActionText + +### Properties + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **message** | `string` | ✅ | The sentence the action's body writes into a record — in the source locale, translated whole through objects.``._actions.``.texts.``.message (globalActions.``.texts.``.message for an object-less action) in the organization's language when the body asks for it (ctx.text). With no params every `{{ }}` hole is refused; with params a hole is a path over one of them with an optional known formatter | +| **params** | `string[]` | optional | The names this text may fill: a `{{ NAME }}` or `{{ NAME \| formatter }}` hole renders the value the action's body passes in ctx.text(KEY, `{ NAME: value }`). A hole over any other name is refused at parse; a hole holding logic, an unknown formatter, an empty hole and a currency formatter with no code are refused where the text is compiled (os validate, compile, the publish gate). Absent: the sentence is plain text and a `{{ }}` hole is refused | + + --- ## ActionType