Skip to content

Commit 1bf90a0

Browse files
feat(spec): BulkActionResultSchema, the per-row outcome an aggregate bulk handler may resolve with (#34267)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9GPcRQy7taMdH7c7xqkajGg)_ Fixes #34216 Reader: #34269 (the grid's bulk reader). Until it lands this shape is `[PLANNED — not enforced]`, and a handler that cannot cover the whole selection must still reject. Clause-②: yes (widening) — a new optional public shape and its three exports (`BulkActionResultSchema`, `BulkActionResult`, `BulkActionResultParsed`) from `@objectstack/spec/ui`; nothing an author writes is accepted or refused differently Metadata-protocol: added Skills-docs: follow-up #34268 — skills/objectstack-ui/rules/actions.md (teach a handler to resolve with the per-row result once the grid reads it; teaching it now would advertise an answer the console does not yet render) ## 维护者速读 - **改了什么**:在动作契约里先声明一个可选的逐行结果结构 `BulkActionResultSchema`(`{ succeeded: [id], failed: [{ id, message }] }`),给「整体执行」(`execution: 'aggregate'`)批量动作的处理器作为返回值用。标为 `[PLANNED — not enforced]`:控制台还不读它,读取方是 #34269;在那之前处理器覆盖不了整批时仍须拒绝。只改 spec,界面和运行时都没动。 - **为什么改**:HotCRM 实测,批量改阶段时一条被拒、另一条其实已改,控制台没法知道是哪条动了。这个结构让处理器能如实说明每一行的结果。 - **风险与回滚**:纯新增导出,现有元数据和处理器不受影响。读取方 #34269 落地前,返回这个结构也会被当成整批成功,所以说明里写明处理器仍须拒绝。回滚即 revert 本 PR。 - **先看**:`packages/spec/src/ui/bulk-action.zod.ts`(新结构和它的说明);`packages/spec/src/ui/bulk-action.test.ts`(新的 describe);`docs/audits/2026-07-unknown-key-strictness-ledger.md`(该文件那一行改成 mixed)。 - **两分钟验证**:`pnpm --filter @objectstack/spec exec vitest run src/ui/bulk-action.test.ts`,预期全绿,新 describe「BulkActionResultSchema — the per-row outcome…」。 - **需要你做的**:无,席位落地。 ## What changes Seat ruling 6905490575 on the card, option A: the per-row result travels as the resolve value only, and the change is spec-only. Round 2 answers review#2 record 6906386763. - `packages/spec/src/ui/bulk-action.zod.ts`: `BulkActionResultSchema` beside `BulkActionExecutionSchema`, with types `BulkActionResult` (input) and `BulkActionResultParsed` (output). Members `{ succeeded: string[], failed: { id: string, message: string }[] }`. - **[PLANNED — not enforced]** in the TSDoc, the describe and the reference page (the #34078 marker). The console does not read the value yet; its reader is #34269. Until that lands a resolved aggregate call counts as covering every selected row, so a handler that cannot cover the whole selection must still reject. - It is declared as the handler's whole resolve value, not a reserved key (so once #34269 lands, a top-level `succeeded` / `failed` member that does not parse is reported unreadable; #34269 declares that change), and never attached to a rejection: the `/actions` door carries no structured body on a script or flow handler's throw (measured in report 6905466421). - Not `BatchUpdateResponse` (there `succeeded` / `failed` are counts, rows under `results`) and not `BulkWriteResult` (`errors[].error`): here they are the row lists and the reason is `message`. - How the reader (#34269) will read it, only on an `execution: 'aggregate'` dispatch: a value with neither member keeps the one-outcome report; a value with either member that does not parse is reported as unreadable, never as full success; members beyond the two lists carry no meaning. - How it will count ids: an id outside `params._selectedIds` is dropped; a duplicate counts once; an id in both lists counts as failed; a selected id in neither list is reported as not confirmed, never as succeeded. - `z.looseObject` at both levels, on purpose: a wire shape a handler writes, not an author. - It is exported through the `ui` barrel (`export * from './bulk-action.zod'`, unchanged). - Regenerated: `api-surface/ui.json`, `export-origins/ui.json`, `declaration-map/ui.json`, `json-schema.manifest/ui.json`, `authorable-surface/ui.json`, `content/docs/references/ui/bulk-action.mdx` and `index.mdx`, and the strictness-ledger counts shard `ui.md`. - Strictness ledger: the `bulk-action.zod.ts` row moves from `authorable` to `mixed` (two wire-class `looseObject` sites, the `PicklistServedFieldSchema` precedent), says the shape is planned with #34269 as its reader, and corrects a stale sentence: `BulkActionParamSchema` is `strictObject`, not `.passthrough()`. Strip sites are unchanged (5 of 223 in `ui/`). - Changeset `.changeset/34216-bulk-action-result.md`: `@objectstack/spec` minor. It declares the shape and its reader #34269, and says a handler must still reject until then; there is no present-tense "resolve instead of throwing" instruction. ## Tests `packages/spec/src/ui/bulk-action.test.ts`, new top-level describe `BulkActionResultSchema — the per-row outcome an aggregate handler may resolve with`: - Accepts the full shape; empty lists (all written, none written, both empty); members beyond the two lists, kept as written. - Refuses a non-string id in either list (`invalid_type` at `succeeded.0` / `failed.0.id`), a `failed` entry without `message`, a value missing either list, and the two neighbouring shapes: `BatchUpdateResponse`'s counts and `BulkWriteResult`'s `errors[].error` (and a `failed` entry spelled with `error`). - The shape admits a duplicate id and an id in both lists; the counting rules are the reader's (#34269). - CONTROL, no per-row result: nothing, null, scalars, an array, and a handler's own `{ ok: true }` or `{ summary }` are not a per-row result. The showcase aggregate def still parses as before. - `a rejection stays the one-outcome report (documents the ruling; not coverage: no reader exists yet)`: the refusal envelope is not a per-row result, even with the shape inside `error.details`. No existing test was edited. ## Acceptance notes - File surface beyond the claim, declared: `docs/audits/2026-07-unknown-key-strictness-ledger.md`. Its `bulk-action.zod.ts` row class moves to `mixed`, because the file now holds a wire shape beside its authoring half. `check:strictness-ledger` checks the row covers the file; the class is the human verdict. - `authorable-surface/ui.json` gains `ui/BulkActionResult:failed` and `:succeeded`. The generator lists every exported object schema's keys; no metadata type carries this shape, so no author writes it into stored metadata; a handler author writes it as a return value. `check-changeset-no-major` reads that shard as an authorable key added, so this PR declares `Metadata-protocol: added` where the claim said `none` (the delta allowed it: "unless the measurement says otherwise"). Declared as a deviation. - The ui reader is #34269 (filed by the seat). Still noted for after merge: the action invocation audit row records `succeeded` for a 200 that carries `failed` rows. ## Verification Round 2 readings on head eb69975 (base main 7be32d3; main is 8 first-parent commits ahead, no file in common with this diff, so not merged: K under 15). <details><summary>Spec suite, typecheck and generated artifacts (round 2)</summary> - `pnpm --filter @objectstack/spec test` (locked): Test Files 844 passed (844), Tests 27017 passed, 1 todo. VERDICT command-exit 0. - `pnpm --filter @objectstack/spec typecheck` (locked): VERDICT command-exit 0. - `bulk-action.test.ts`: 51 passed (51). - `check:generated --fix` after the describe change rewrote only `content/docs/references/ui/bulk-action.mdx` (the reference page now opens with the planned marker). - `check-changeset-no-major --base 7be32d3 --event` on this body, `check-partof-closing-keyword` on this body, `check-empty-changeset`, `check-adr-0087-registration`: exit 0. </details> <details><summary>Ablation (round 1, schema code unchanged since)</summary> Committed first (ea22bdd); each leg red, restored clean: `failed[].message` optional reds the missing-message pin; `succeeded` items `z.unknown()` reds the non-string-id pin; outer `looseObject` to `object` reds the extra-members pin. Round 2 changed only prose and added pins, not the schema's code. </details> <details><summary>Derived gates: 109 of 109, exit 0 (round 2)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` on eb69975 derived the same 109 families as round 1; all 109 exit 0. `--ran`: 109 derived, 109 run, 0 NOT-MEASURED, 0 UNRUN. `check:dev-prereqs` (local-only) stays NOT MEASURED: `ui/` is unbuilt in this container. </details> Dogfood battery: not run, because the title has no `!` and there is no `(narrowing)` arm. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmNf3y1gdYzp1F6sSLY)_ --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmNf3y1gdYzp1F6sSLY <!-- signed: domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bdd5176 commit 1bf90a0

12 files changed

Lines changed: 247 additions & 14 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): `BulkActionResultSchema`, the per-row outcome an `execution: 'aggregate'` bulk action handler may resolve with
6+
7+
Clause-②: yes (widening) — a new optional public shape and its three exports (`BulkActionResultSchema`, `BulkActionResult`, `BulkActionResultParsed`) from `@objectstack/spec/ui`; nothing an author writes is accepted or refused differently
8+
Metadata-protocol: added
9+
10+
An aggregate bulk action is ONE dispatch for the whole selection, with every id in `params._selectedIds`. A handler that writes row by row can move some rows and fail on others, and the action contract had no declared way to say which: the grid can only report one outcome for the selection.
11+
12+
`BulkActionResultSchema` (`@objectstack/spec/ui`, beside `BulkActionExecutionSchema`) declares that answer, ahead of its reader:
13+
14+
```ts
15+
{ succeeded: string[]; failed: { id: string; message: string }[] }
16+
```
17+
18+
- **[PLANNED — not enforced].** The console does not read this value yet; its reader is the grid's bulk reader, objectstack#34269. Until that lands, a resolved aggregate call is counted as covering every selected row, so **a handler that cannot cover the whole selection must still reject.**
19+
- It is declared as the handler's whole RESOLVE value, never attached to a rejection: a rejection stays one outcome for the selection, because the `/actions` door carries no structured body on a script or flow handler's throw.
20+
- It is not the data plane's batch answer: here `succeeded` and `failed` are the row lists, not counts, and a failure's reason is `message`.
21+
- Once read, only for an `execution: 'aggregate'` dispatch: a value with neither member keeps the one-outcome report; a value with either member that does not parse is reported as unreadable, never as full success; members beyond the two lists carry no meaning.
22+
- Ids must be dispatched `params._selectedIds`: an id outside the selection is dropped, a duplicate counts once, an id in both lists counts as failed, and a selected id in neither list is reported as not confirmed, never as succeeded.
23+
24+
FROM no declared per-row answer for an aggregate handler TO a declared, exported `BulkActionResultSchema` whose reader is objectstack#34269. Nothing to migrate, and nothing to change in a handler today: until the reader lands, keep rejecting when the whole selection is not covered.

‎content/docs/references/index.mdx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Protocol reference — every schema by module
33
navTitle: Protocol Reference
4-
description: Every schema published by @objectstack/spec — 1665 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1666 schemas across 14 protocol modules
55
---
66

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

3939
---
4040

@@ -385,7 +385,7 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a
385385

386386
## UI Protocol
387387

388-
**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 176 schemas**
388+
**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 177 schemas**
389389

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

@@ -394,7 +394,7 @@ Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI lay
394394
| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionType`, `InlineAction` |
395395
| [`action-params.zod.ts`](/docs/references/ui/action-params) | `ActionSession` |
396396
| [`app.zod.ts`](/docs/references/ui/app) | `ActionNavItem`, `App`, `AppBranding`, `AppContextSelector`, `AppLandingEntry`, `ComponentNavItem`, `DashboardNavItem`, `DocNavItem`, `GroupNavItem`, `NavigationArea`, `NavigationContribution`, `NavigationItem`, `ObjectNavItem`, `PageNavItem`, `ReportNavItem`, `UrlNavItem` |
397-
| [`bulk-action.zod.ts`](/docs/references/ui/bulk-action) | `BulkActionDef`, `BulkActionExecution`, `BulkActionOperation`, `BulkActionParam` |
397+
| [`bulk-action.zod.ts`](/docs/references/ui/bulk-action) | `BulkActionDef`, `BulkActionExecution`, `BulkActionOperation`, `BulkActionParam`, `BulkActionResult` |
398398
| [`chart.zod.ts`](/docs/references/ui/chart) | `ChartAggregate`, `ChartAggregateFunction`, `ChartAnnotation`, `ChartAxis`, `ChartConfig`, `ChartDrillDown`, `ChartGroupBy`, `ChartInteraction`, `ChartSeries`, `ChartType` |
399399
| [`component.zod.ts`](/docs/references/ui/component) | `ActionButtonProps`, `ActionGroupProps`, `ActionIconProps`, `ActionMenuProps`, `ElementButtonProps`, `ElementDefinitionListProps`, `ElementFilterProps`, `ElementFormProps`, `ElementImageProps`, `ElementMetadataViewerProps`, `ElementNumberProps`, `ElementRecordPickerProps`, `ElementRepeaterProps`, `ElementTextInputProps`, `ElementTextProps`, `ObjectCalendarProps`, `ObjectFormProps`, `ObjectGanttProps`, `ObjectGridProps`, `ObjectKanbanProps`, `ObjectMapProps`, `ObjectMasterDetailFormProps`, `ObjectMetricProps`, `ObjectTimelineProps`, `ObjectTreeProps`, `PageAccordionProps`, `PageCardProps`, `PageContainerProps`, `PageHeaderProps`, `PageTabsProps`, `RecordActivityProps`, `RecordAlertAction`, `RecordAlertProps`, `RecordChatterProps`, `RecordDetailsProps`, `RecordHighlightsField`, `RecordHighlightsProps`, `RecordHistoryProps`, `RecordLineItemsProps`, `RecordPathProps`, `RecordQuickActionsProps`, `RecordReferenceRailProps`, `RecordRelatedListProps`, `ReferenceRailEntry` |
400400
| [`dashboard.zod.ts`](/docs/references/ui/dashboard) | `Dashboard`, `DashboardHeader`, `DashboardHeaderAction`, `DashboardWidget`, `DashboardWidgetChartConfig`, `DashboardWidgetOptions`, `GlobalFilter`, `GlobalFilterOptionsFrom`, `WidgetActionType`, `WidgetColorVariant` |

‎content/docs/references/ui/bulk-action.mdx‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ action's own label, params and `visible`.
2525
## TypeScript Usage
2626

2727
```typescript
28-
import { BulkActionDefSchema, BulkActionExecutionSchema, BulkActionOperationSchema, BulkActionParamSchema } from '@objectstack/spec/ui';
29-
import type { BulkActionDef, BulkActionExecution, BulkActionOperation, BulkActionParam } from '@objectstack/spec/ui';
28+
import { BulkActionDefSchema, BulkActionExecutionSchema, BulkActionOperationSchema, BulkActionParamSchema, BulkActionResultSchema } from '@objectstack/spec/ui';
29+
import type { BulkActionDef, BulkActionExecution, BulkActionOperation, BulkActionParam, BulkActionResult } from '@objectstack/spec/ui';
3030

3131
// Validate data
3232
const result = BulkActionDefSchema.parse(data);
@@ -177,3 +177,24 @@ const result = BulkActionDefSchema.parse(data);
177177

178178
---
179179

180+
## BulkActionResult
181+
182+
[PLANNED — not enforced] The per-row outcome an `execution: 'aggregate'` bulk action handler MAY resolve with: `{ succeeded: [ids], failed: [{ id, message }] }` as its whole resolve value, never attached to a rejection (a rejection stays one outcome for the selection). The console does not read it yet, so until its reader lands a handler that cannot cover the whole selection must still reject: a resolved aggregate call is counted as covering every selected row. Not the data plane's batch answer: here `succeeded` and `failed` are row lists, not counts. Once read: a value with neither member keeps the one-outcome report; a value with either member that does not parse is reported as unreadable, never as full success; members beyond the two lists carry no meaning. Ids must be dispatched `params._selectedIds`: an id outside the selection is dropped, a duplicate counts once, an id in both lists counts as failed, and a selected id in neither list is reported as not confirmed, never as succeeded.
183+
184+
### Properties
185+
186+
| Property | Type | Required | Description |
187+
| :--- | :--- | :--- | :--- |
188+
| **succeeded** | `string[]` | ✅ | Ids of the selected rows the handler wrote. Each must be one of the dispatched `params._selectedIds`. The planned reader will drop an id outside the selection, count a duplicate once, and count an id that is also in `failed` as failed. |
189+
| **failed** | `({ id: string; message: string } & Record<string, any>)[]` | ✅ | One entry per selected row the handler did not write, each with its own reason (`message`, not `error`). The planned reader will drop an id outside `params._selectedIds` and count a duplicate once. |
190+
191+
### Nested Shape: `BulkActionResult.failed[number]`
192+
193+
| Property | Type | Required | Description |
194+
| :--- | :--- | :--- | :--- |
195+
| **id** | `string` | ✅ | Id of a selected row the handler did not write: one of the dispatched `params._selectedIds`. |
196+
| **message** | `string` | ✅ | Why this row was not written, as the person running the action should read it. |
197+
198+
199+
---
200+

‎docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The `strict` column is the one the campaign schedules against; it counts both th
2121

2222
| Dir | Sites | strict | passthrough | catchall | strip |
2323
|---|---|---|---|---|---|
24-
| `ui/` | 221 | 212 | 4 | 0 | 5 |
24+
| `ui/` | 223 | 212 | 6 | 0 | 5 |
2525

2626
## `ui/` — sites
2727

@@ -34,7 +34,7 @@ classify and is not listed (it becomes reportable the day it grows its first sit
3434
| `action-params.zod.ts` | 1 |
3535
| `action.zod.ts` | 12 |
3636
| `app.zod.ts` | 20 |
37-
| `bulk-action.zod.ts` | 4 |
37+
| `bulk-action.zod.ts` | 6 |
3838
| `chart.zod.ts` | 8 |
3939
| `component.zod.ts` | 81 |
4040
| `dashboard.zod.ts` | 11 |
@@ -46,23 +46,23 @@ classify and is not listed (it becomes reportable the day it grows its first sit
4646
| `sharing.zod.ts` | 1 |
4747
| `view.zod.ts` | 59 |
4848
| `widget.zod.ts` | 1 |
49-
| **total** | **221** |
49+
| **total** | **223** |
5050

5151
## `ui/` — open
5252

5353
Per file, how many of its sites still silently discard unknown keys. The `Class`
5454
column that decides the bucket split is hand-written in the ledger; the arithmetic
5555
over it is here.
5656

57-
**5 strip of 221**, in 4 file(s).
57+
**5 strip of 223**, in 4 file(s).
5858

5959
| File | Strip | Sites |
6060
|---|---|---|
6161
| `action-params.zod.ts` | 1 | 1 |
6262
| `app.zod.ts` | 1 | 20 |
6363
| `view.zod.ts` | 2 | 59 |
6464
| `widget.zod.ts` | 1 | 1 |
65-
| **total** | **5** | **221** |
65+
| **total** | **5** | **223** |
6666

6767
| Bucket | Sites |
6868
|---|---|

0 commit comments

Comments
 (0)