Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5bbad5f
feat(spec): an action declares a refusal catalogue, the hook catalogu…
claude Nov 16, 2026
96e562a
wip(runtime,lint): answer an action body's throw against its refusal …
claude Nov 16, 2026
060c058
fix(spec, lint, runtime): carry the action refusal work onto main bes…
claude Nov 17, 2026
7e9f806
feat(spec, runtime, lint): an action's refusal catalogue — validate, …
claude Nov 17, 2026
aa82106
chore(spec, lint, metadata-protocol): regenerate artifacts and record…
claude Nov 17, 2026
a9acead
test(lint): classify the action refusal template pass in the authored…
claude Nov 17, 2026
6f4692b
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
04a9166
fix(spec, runtime): llms.txt counts the declared-entry module; the ac…
claude Nov 17, 2026
2b11c5b
fix(ui-core): list refusals among the spec's declared action keys
claude Nov 17, 2026
2a25dad
docs(protocol): the action shape lists refusals
claude Nov 17, 2026
f1e72a9
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
ff1ba66
chore(spec): regenerate the action liveness counts over the merge wit…
claude Nov 17, 2026
0169fc1
fix(spec): the action refusal sentences and changeset say what the di…
claude Nov 17, 2026
e8d6c73
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
b7d720d
docs(references): regenerate index after main merge
claude Nov 17, 2026
b992507
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
5a05e4f
docs(references): regenerate translation reference after main merge
claude Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/34273-action-refusals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@objectstack/spec': minor
'@objectstack/runtime': minor
'@objectstack/lint': minor
'@object-ui/core': patch
---

feat(actions): an action body refuses in the caller's language through a declared refusal catalogue

Clause-②: yes (widening) — an action may now declare `refusals` (`ActionRefusalSchema`); translation bundles accept `objects.<object>._actions.<action>.refusals.<CODE>.message` and `globalActions.<action>.refusals.<CODE>.message` (with `….reasons.<REASON>.message`); `@objectstack/spec` exports `ActionRefusalSchema` and the `ActionRefusal` type (`ui`), `actionRefusalMessageKey` (`system`), and `ACTION_REFUSAL_MESSAGE_HOLE_REFUSED`, `actionRefusalsWithoutSandboxedBody`, `undeclaredActionRefusalCodeAtSave`, `undeclaredActionRefusalReasonAtSave`, `undeclaredActionRefusalAtRun` and `undeclaredActionRefusalReasonAtRun` (`data`); `@objectstack/runtime` adds no export: the action body runner answers through `resolveActionRefusal` internally. Nothing that was accepted before is refused
Metadata-protocol: added
Skills-docs: follow-up #34824 — `skills/objectstack-i18n/SKILL.md` lists the hook refusal key only and `skills/objectstack-ui/rules/actions.md` teaches no action `refusals`; `content/docs/ui/actions.mdx` and `content/docs/ui/translations.mdx` gain the section and the key row here

A `script` action's `js` body can now refuse the way a hook does: declare the refusals it may throw, keyed by code, and throw the code instead of the sentence — `refusals: { NOT_DRAFT: { message: 'Only a draft invoice can be signed off.', status: 409 } }`, then `throw { code: 'NOT_DRAFT' }`. The server answers with the entry's sentence in the caller's locale (the request's `executionContext.locale`), else the declared one, on the refusal's `userMessage`, with the entry's status (400 when it names none). The entry is the hook catalogue's, built by one shared factory: optional `reasons` (further sentences under one code) and `params` (the names a `{{ }}` hole may fill), under the same rules.

- The translation sits beside the action's other copy: `objects.<object>._actions.<action>.refusals.<CODE>.message` for an action bound to an object, `globalActions.<action>.refusals.<CODE>.message` for an object-less one. `os i18n extract` scaffolds the keys and the coverage check counts them; `objectstack validate` refuses a translation over a code or reason the action does not declare.
- A code the catalogue does not declare, a reason a code with `reasons` does not declare, or a throw with no code is refused: at save when the body names it literally, otherwise when it runs, as a fault naming the action and the code. An error a `ctx.api` call raised and the body let through unchanged passes through as before, and so does a crash.
- `refusals` is read only for a `type: 'script'` action with a `js` body (an inline `target` function is lowered to one by `os build`); on any other action, or with no body, it is refused at save.
- A sentence with `params` is compiled like a hook's: `objectstack validate`, `compile` and the publish gate refuse a hole holding logic, an unknown formatter, an empty hole and `{{ amount | currency }}` with no code.
- An action without `refusals` is answered exactly as before.

The shared declared-entry factory (`packages/spec/src/data/declared-entry.zod.ts`) now builds `HookRefusalSchema`, `ActionRefusalSchema` and `HookTextSchema`; the published hook schemas are unchanged.

`@object-ui/core` lists `refusals` among the spec's declared action keys, so an action carrying a catalogue is not reported as having an unknown key; the console reads nothing new, because the refusal arrives already rendered on `userMessage`.
1 change: 1 addition & 0 deletions content/docs/protocol/objectui/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ interface Action {
operation?: 'update'; // Declarative single-record field write (rides the default script route)
patch?: Record<string, unknown>; // Static field values for operation: 'update', merged under params
body?: HookBody; // Inline logic for type: 'script'
refusals?: Record<string, ActionRefusal>; // Codes the js body may throw, answered with a declared sentence in the caller's locale
params?: ActionParam[]; // Inputs collected before execution
submitText?: I18nLabel; // The param dialog's submit button verb (default "Confirm")
cancelText?: I18nLabel; // The confirm or param dialog's dismiss button label (default "Cancel")
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/data/object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ const result = ApiMethod.parse(data);
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |
| **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<string, { message: string; status?: integer; reasons?: Record<string, object>; 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.`<object>`._actions.`<action>`.refusals.`<CODE>`.message, or globalActions.`<action>`.refusals.`<CODE>`.message for an object-less action, ….reasons.`<REASON>`.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 |
| **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<string, any>` | 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: ['<name>']` 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`). |
Expand Down
10 changes: 5 additions & 5 deletions content/docs/references/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Protocol reference — every schema by module
navTitle: Protocol Reference
description: Every schema published by @objectstack/spec — 1670 schemas across 14 protocol modules
description: Every schema published by @objectstack/spec — 1671 schemas across 14 protocol modules
---

{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
Expand Down Expand Up @@ -33,8 +33,8 @@ counts are sums of the rows they head. Regenerate with
| [Shared Protocol](/docs/references/shared) | 10 | 31 | Primitives used across every protocol — identifiers, HTTP, expressions, error maps, enums. |
| [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. |
| [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. |
| [UI Protocol](/docs/references/ui) | 16 | 177 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
| **Total** | **218** | **1670** | 14 protocol modules |
| [UI Protocol](/docs/references/ui) | 16 | 178 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
| **Total** | **218** | **1671** | 14 protocol modules |

---

Expand Down Expand Up @@ -385,13 +385,13 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a

## UI Protocol

**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 177 schemas**
**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 178 schemas**

Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer.

| File | Schemas |
| :--- | :--- |
| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionType`, `InlineAction` |
| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionRefusal`, `ActionType`, `InlineAction` |
| [`action-params.zod.ts`](/docs/references/ui/action-params) | `ActionSession` |
| [`app.zod.ts`](/docs/references/ui/app) | `ActionNavItem`, `App`, `AppBranding`, `AppContextSelector`, `AppLandingEntry`, `ComponentNavItem`, `DashboardNavItem`, `DocNavItem`, `GroupNavItem`, `NavigationArea`, `NavigationContribution`, `NavigationItem`, `ObjectNavItem`, `PageNavItem`, `ReportNavItem`, `UrlNavItem` |
| [`bulk-action.zod.ts`](/docs/references/ui/bulk-action) | `BulkActionDef`, `BulkActionExecution`, `BulkActionOperation`, `BulkActionParam`, `BulkActionResult` |
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/kernel/metadata-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ const result = MetadataBulkResultSchema.parse(data);
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |
| **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<string, { message: string; status?: integer; reasons?: Record<string, object>; 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.`<object>`._actions.`<action>`.refusals.`<CODE>`.message, or globalActions.`<action>`.refusals.`<CODE>`.message for an object-less action, ….reasons.`<REASON>`.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 |
| **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<string, any>` | 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: ['<name>']` 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`). |
Expand Down
5 changes: 5 additions & 0 deletions content/docs/references/system/translation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Translation data for a single field
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |

### Nested Shape: `ObjectTranslationData._sections[string]`

Expand Down Expand Up @@ -244,6 +245,7 @@ Translation data for a single object
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |

### Nested Shape: `PlatformTranslationData.dashboards[string]`

Expand Down Expand Up @@ -424,6 +426,7 @@ Translation data for a single object
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |

### Nested Shape: `ServedTranslationData.dashboards[string]`

Expand Down Expand Up @@ -667,6 +670,7 @@ Translation data for a single object
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |

### Nested Shape: `TranslationData.dashboards[string]`

Expand Down Expand Up @@ -879,6 +883,7 @@ Translation data for a single object
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |

### Nested Shape: `TranslationItem.dashboards[string]`

Expand Down
Loading
Loading