diff --git a/.changeset/34216-bulk-action-result.md b/.changeset/34216-bulk-action-result.md new file mode 100644 index 00000000000..d70790ff674 --- /dev/null +++ b/.changeset/34216-bulk-action-result.md @@ -0,0 +1,24 @@ +--- +'@objectstack/spec': minor +--- + +feat(spec): `BulkActionResultSchema`, the per-row outcome an `execution: 'aggregate'` bulk action handler may resolve with + +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 + +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. + +`BulkActionResultSchema` (`@objectstack/spec/ui`, beside `BulkActionExecutionSchema`) declares that answer, ahead of its reader: + +```ts +{ succeeded: string[]; failed: { id: string; message: string }[] } +``` + +- **[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.** +- 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. +- 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`. +- 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. +- 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. + +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. diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index 81db3f38a2c..368db4fafcc 100644 --- a/content/docs/references/index.mdx +++ b/content/docs/references/index.mdx @@ -1,7 +1,7 @@ --- title: Protocol reference — every schema by module navTitle: Protocol Reference -description: Every schema published by @objectstack/spec — 1665 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1666 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/. */} @@ -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 | 176 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **218** | **1665** | 14 protocol modules | +| [UI Protocol](/docs/references/ui) | 16 | 177 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | +| **Total** | **218** | **1666** | 14 protocol modules | --- @@ -385,7 +385,7 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a ## UI Protocol -**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 176 schemas** +**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 177 schemas** Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. @@ -394,7 +394,7 @@ Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI lay | [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `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` | +| [`bulk-action.zod.ts`](/docs/references/ui/bulk-action) | `BulkActionDef`, `BulkActionExecution`, `BulkActionOperation`, `BulkActionParam`, `BulkActionResult` | | [`chart.zod.ts`](/docs/references/ui/chart) | `ChartAggregate`, `ChartAggregateFunction`, `ChartAnnotation`, `ChartAxis`, `ChartConfig`, `ChartDrillDown`, `ChartGroupBy`, `ChartInteraction`, `ChartSeries`, `ChartType` | | [`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` | | [`dashboard.zod.ts`](/docs/references/ui/dashboard) | `Dashboard`, `DashboardHeader`, `DashboardHeaderAction`, `DashboardWidget`, `DashboardWidgetChartConfig`, `DashboardWidgetOptions`, `GlobalFilter`, `GlobalFilterOptionsFrom`, `WidgetActionType`, `WidgetColorVariant` | diff --git a/content/docs/references/ui/bulk-action.mdx b/content/docs/references/ui/bulk-action.mdx index 17e5c3e32e3..4eed67bf702 100644 --- a/content/docs/references/ui/bulk-action.mdx +++ b/content/docs/references/ui/bulk-action.mdx @@ -25,8 +25,8 @@ action's own label, params and `visible`. ## TypeScript Usage ```typescript -import { BulkActionDefSchema, BulkActionExecutionSchema, BulkActionOperationSchema, BulkActionParamSchema } from '@objectstack/spec/ui'; -import type { BulkActionDef, BulkActionExecution, BulkActionOperation, BulkActionParam } from '@objectstack/spec/ui'; +import { BulkActionDefSchema, BulkActionExecutionSchema, BulkActionOperationSchema, BulkActionParamSchema, BulkActionResultSchema } from '@objectstack/spec/ui'; +import type { BulkActionDef, BulkActionExecution, BulkActionOperation, BulkActionParam, BulkActionResult } from '@objectstack/spec/ui'; // Validate data const result = BulkActionDefSchema.parse(data); @@ -177,3 +177,24 @@ const result = BulkActionDefSchema.parse(data); --- +## BulkActionResult + +[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. + +### Properties + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **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. | +| **failed** | `({ id: string; message: string } & Record)[]` | ✅ | 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. | + +### Nested Shape: `BulkActionResult.failed[number]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **id** | `string` | ✅ | Id of a selected row the handler did not write: one of the dispatched `params._selectedIds`. | +| **message** | `string` | ✅ | Why this row was not written, as the person running the action should read it. | + + +--- + diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md index 105954b2bc8..e8aab02b778 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md @@ -21,7 +21,7 @@ The `strict` column is the one the campaign schedules against; it counts both th | Dir | Sites | strict | passthrough | catchall | strip | |---|---|---|---|---|---| -| `ui/` | 221 | 212 | 4 | 0 | 5 | +| `ui/` | 223 | 212 | 6 | 0 | 5 | ## `ui/` — sites @@ -34,7 +34,7 @@ classify and is not listed (it becomes reportable the day it grows its first sit | `action-params.zod.ts` | 1 | | `action.zod.ts` | 12 | | `app.zod.ts` | 20 | -| `bulk-action.zod.ts` | 4 | +| `bulk-action.zod.ts` | 6 | | `chart.zod.ts` | 8 | | `component.zod.ts` | 81 | | `dashboard.zod.ts` | 11 | @@ -46,7 +46,7 @@ classify and is not listed (it becomes reportable the day it grows its first sit | `sharing.zod.ts` | 1 | | `view.zod.ts` | 59 | | `widget.zod.ts` | 1 | -| **total** | **221** | +| **total** | **223** | ## `ui/` — open @@ -54,7 +54,7 @@ Per file, how many of its sites still silently discard unknown keys. The `Class` column that decides the bucket split is hand-written in the ledger; the arithmetic over it is here. -**5 strip of 221**, in 4 file(s). +**5 strip of 223**, in 4 file(s). | File | Strip | Sites | |---|---|---| @@ -62,7 +62,7 @@ over it is here. | `app.zod.ts` | 1 | 20 | | `view.zod.ts` | 2 | 59 | | `widget.zod.ts` | 1 | 1 | -| **total** | **5** | **221** | +| **total** | **5** | **223** | | Bucket | Sites | |---|---| diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.md b/docs/audits/2026-07-unknown-key-strictness-ledger.md index 7486a0b5f29..41118af139a 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.md @@ -672,7 +672,7 @@ sites left to be a verdict about. | `action.zod.ts` | authorable | **strict as of #4001 批 14 — 0 strip sites remain.** `ActionParamSchema` was strict from #3746, but strictness does not recurse and its `options[]` entry was still strip: an option carrying `color` / `visibleWhen` / `icon` / `disabled` parsed clean through `getMetadataTypeSchema('action')` and came back `{ label, value }`. Closed with `strictObject`, NOT `.passthrough()` — the opposite call from `bulk-action.zod.ts`'s option entry two rows up, and made on measurement rather than symmetry: that def reaches the grid verbatim with no spec door in between and objectui's `BulkActionParam` declares an explicit `[key: string]: unknown`, whereas this path has a door that ALREADY strips and lands in the CLOSED `SelectOptionMetadata`. Whether this surface should carry the field-level per-option vocabulary at all is #5016. Earlier note: **9 → 8 at the #4001 re-measurement** — no schema changed; the ninth "site" was a `z.object(…)` inside a JSDoc paragraph, which the old textual counter could not tell from code **9 → 8 at the #4001 re-measurement** — no schema changed: the ninth "site" was a `z.object(…)` inside a JSDoc paragraph, which the old textual counter could not tell from code | | `action-params.zod.ts` | wire | **never strict, deliberately** — one site: `ActionSessionSchema`, the action-body `ctx.session` declared at **#5697** (phase 1 of #5613's contract-first ruling). It is the RUNTIME shape `packages/runtime`'s `buildActionSession()` hands a body, not an authoring surface — nobody writes it — so closing it would turn a future engine-side enrichment into a parse failure for whoever parses a context they were GIVEN: the same call, and the same reason, as `data/hook.zod.ts`'s `HookContextSchema` row. The file had no row until now because everything else it exports is a function or an interface (`validateActionParams`, `ActionHandlerContext`), i.e. zero sites to classify. ⚠️ **Read the arrival direction, because it is the opposite of every other row in this table**: this site did not survive a strictness sweep, it is NEW surface — a shape that was being produced with no declaration anywhere (`actionContext` is a bare `any` at both dispatch sites), which is why neither this ledger nor any gate could see that its `roles` key carries `ExecutionContext.positions` under the spelling ADR-0090 D3 forbids. The key is declared as-built and marked deprecated in its `.describe()`; the rename is #5613 phase 2. A declaration is not an endorsement — do not read this row as "the shape is settled" | | `view.zod.ts` | authorable | partially strict (ADR-0089); long tail of sub-blocks. `bulkActionDefs` left this file in #4457 — see the row below | -| `bulk-action.zod.ts` | authorable | **strict as of #4457** — `BulkActionDefSchema` (the def itself). It was `z.array(z.record(z.string(), z.any()))` inline in `view.zod.ts`: a selection-bar button with **no shape at all**, so `opeartion` / `excution: 'aggregate'` parsed and shipped as a button that ran the default behaviour. Its two other sites are `BulkActionParamSchema` and that param's `options` entry, both deliberately **open** and both now `.passthrough()` — the param because objectui's `BulkActionParam` declares a `[key: string]: unknown` catch-all for widget config (min/max/step/format), so passthrough is the honest mirror and strictness would reject valid config (same call as `dashboard.zod.ts`'s widget `config`); the OPTION ENTRY on separate measured evidence, since its objectui type is closed and only the runtime path is open — `bulkParamToField` spreads each entry (`plugin-grid/src/components/bulkParamToField.ts:131`) into `SelectOptionMetadata` (`types/src/field-types.ts:288`), which declares and reads `color` / `icon` / `disabled` / `visibleWhen`. **This row said "both deliberately open" while only the parent was `passthrough`** — one intent, two postures, caught by the 2026-08-03 re-measure and closed by the ruling's verdict A (make the code match the prose). The lesson is the campaign's own: prose in this ledger is not a posture reading, which is why the remaining-strip map is gated and this column is not. The def also refuses the combinations the executor never reads (`patch` outside an update, `execution` outside a custom, `batchSize` on an aggregate) and a hand-written `actionDef`, which is renderer-attached | +| `bulk-action.zod.ts` | mixed | **Mixed since #34216**: `BulkActionResultSchema` and its `failed` entry are a WIRE shape — the per-row outcome an `execution: 'aggregate'` handler may resolve with, written by the handler, never by an author — so both are `z.looseObject` by design (members beyond `succeeded` / `failed` are tolerated and given no meaning; the `PicklistServedFieldSchema` call one directory over). **[PLANNED — not enforced]**: nothing reads it yet; the reader (#34269, the grid's bulk reader) will, and until it lands a handler that cannot cover the whole selection must still reject. Everything below is the file's authoring half. **strict as of #4457** — `BulkActionDefSchema` (the def itself). It was `z.array(z.record(z.string(), z.any()))` inline in `view.zod.ts`: a selection-bar button with **no shape at all**, so `opeartion` / `excution: 'aggregate'` parsed and shipped as a button that ran the default behaviour. Its two other authoring sites are `BulkActionParamSchema`, **strict** (`strictObject`) since commit adabccf5f (ruling batch #146 item 4, letter A: it had been `.passthrough()`, mirroring objectui's `BulkActionParam` `[key: string]: unknown` catch-all, which made its accept a null reading; the widget-config keys that catch-all forwarded are now refused with a prescription naming where that vocabulary is real), and that param's `options` entry, deliberately **open** (`.passthrough()`) on separate measured evidence, since its objectui type is closed and only the runtime path is open — `bulkParamToField` spreads each entry (`plugin-grid/src/components/bulkParamToField.ts:131`) into `SelectOptionMetadata` (`types/src/field-types.ts:288`), which declares and reads `color` / `icon` / `disabled` / `visibleWhen`. **This row said "both deliberately open" while only the parent was `passthrough`** — one intent, two postures, caught by the 2026-08-03 re-measure and closed by the ruling's verdict A (make the code match the prose). The lesson is the campaign's own: prose in this ledger is not a posture reading, which is why the remaining-strip map is gated and this column is not. The def also refuses the combinations the executor never reads (`patch` outside an update, `execution` outside a custom, `batchSize` on an aggregate) and a hand-written `actionDef`, which is renderer-attached | | `component.zod.ts` | ~~authorable (p)~~ ~~no gate~~ **authorable (gate wired at #5068)** | **strict as of #4001 batch A — 0 strip sites remain (all 31).** The `(gate wired at #5068)` qualifier is spent in its turn: the parse it wired is now a parse of CLOSED shapes, so an undeclared prop is reported by `safeParse` as `unrecognized_keys` rather than reconstructed by the walker — same rule id, same warning tier, one fewer moving part. What batch A did NOT do is the half this row keeps insisting on: the carrier is still `z.record(z.string(), z.unknown())` (direction B stays declined), and the storage path still parses no props at all (#4463), so this closes the AUTHORING door and nothing else. Three renderer-honoured keys were DECLARED in the same pass rather than rejected — `page:header` `maxVisible`/`mobileMaxVisible`, `page:tabs.alwaysShowStrip`, `record:details` `inlineEdit`/`showHeader` — each read by objectui through `schema?.X ?? schema?.properties?.X` with its own comment inviting authors, which is the #5611/#5775/#6276 rule applied a fourth time (enumerate by the RENDERER'S read pattern, not by the key list a previous ruling quoted). The evidence below is unchanged and still the reason the file took this long. **no parse anywhere (measured, #4001 批 17; the parse landed at #5068 — see the end of this cell)** — the `(p)` resolved NEGATIVE, and this is the campaign's largest single reclassification. The standing warning said to verify objectui's React-prop open slots first; doing so found the question was moot one level up. **The carrier is live but it is an open bag**: `PageComponentSchema.properties` is `z.record(z.string(), z.unknown())`, and although `PageComponentSchema` has been `.strict()` since ADR-0089 D3a, **strictness does not recurse** — it closes the component node's own keys and leaves everything under `properties` unchecked. Nothing dispatches `ComponentPropsMap` by `type`. Three measurements on 2026-08-04, controls green in the same run: (1) a BFS from all 24 metadata-type roots plus `ObjectStackSchema`, over a 6899-node closure built with `build-schemas.ts`'s own `zodChildSchemas`/`zodShapeOf` (the #4650 walk), returns **UNREACHABLE for all 52 targets** (21 exported schemas + every one of `ComponentPropsMap`'s 31 entries), while `PageSchema`/`PageComponentSchema`/`PageRegionSchema`/`ThemeSchema`/`ChartConfigSchema`/`ResponsiveConfigSchema` all resolve `root-graph` and 批 13's no-door shapes stay unreachable — the walk stops dead at `properties`. ⚠️ The #5056 bridge defect does not touch this row: it makes the derived-clone bridge report dead shapes as REACHABLE, the opposite direction, and nothing here rests on that bridge — all six positive controls resolve `root-graph` and all 52 targets miss BOTH `root-graph` and `derived-clone`; (2) across `objectstack`, `objectui` and `cloud`, every `.parse()`/`.safeParse()` on anything in this file is inside the file's own unit tests — objectui mirrors the props as hand-written React interfaces and imports only the inferred TYPES, `cloud` references none, and `react-blocks.ts` uses `Object.keys(ComponentPropsMap)` for type NAMES only (its `REACT_BLOCKS[].schema` entries all point at view/chart schemas); (3) empirically through the live door — `definePage()` IS `PageSchema.parse()` — an undeclared key written inside `components[].properties` parses clean and is RETAINED on 10/10 example-corpus pages, while the same key one level out is rejected on 10/10 (the negative control that makes the first number mean anything). ⚠️ **`no gate`, not `no door`** — the vocabulary is ALIVE and must not be retired: objectui's `SchemaRenderer` hoists `properties` onto the node and spreads every key not on its fixed deny-list straight into the React component, so a misspelled key is neither rejected nor dropped — it reaches the renderer and is ignored there, the ADR-0078 failure mode one layer below where this ratchet reaches. That IS the #4909 open-slot shape, but `.passthrough()` would be exactly as vacuous as `.strict()` on a schema nothing parses, so no posture change was made. The fix is to wire the parse at the carrier's own gate — a `packages/lint`/carrier change, filed as **#5068**, which also records the two constraints that stop it being a drive-by: `type` is an open union (`z.union([PageComponentType, z.string()])`, so `record:line_items`-style unregistered types are authored in the wild) and real pages already author shapes these schemas do not declare (`record:details` `sections[].fields[]`/`hideFields[]`, the record picker's `labelField` — `packages/lint/src/validate-page-field-bindings.ts` has documented the untyped bag all along). **Do not reschedule this as strictness work** — that is what the `(p)` was for, and it has been answered. ✅ **#5068 answered it in turn: the parse is wired (lint side, warning level) and the class is `authorable` again** — the strip-table row below carries the full flip, including the three things it did not do. One correction belongs here rather than there, because this row is where the wrong expectation was written down: the pin in `component.test.ts` said its carrier assertion *"goes red the day `properties` gets a typed dispatch"*, which assumed direction B. The dispatch that landed is direction A — on `packages/lint`'s authoring gate — so the assertion is GREEN after the fix, and it was measured that way rather than predicted. The pin now says which dispatch landed and what a future red there would mean (the carrier reshaped: a protocol change, not a lint one). Recorded in three places (file header, `component.test.ts` pin, this row) | | `app.zod.ts` | authorable | **strict as of #4001 PR B** — `AppSchema` + branding / area / context-selector / contribution, and the nav-item union converted to `z.discriminatedUnion('type', …)` (the union-error question, settled empirically: matched-branch-only errors, exact recursive paths, `toJSONSchema` clean). Per-target `params` stay open. PR A (#4142) tombstoned the seven audit-dead keys first | | `dashboard.zod.ts` | authorable | **strict as of #4001 批 14 — 0 strip sites remain.** `DashboardWidgetSchema` has been strict since the ADR-0021 cutover; 批 14 closed the two NESTED holes inside it (`compareTo`'s object arm, `layout`), the same strict-shell-over-strip-children silhouette 批 13 found on `page.components[]`. `DashboardWidgetOptionsSchema` stays `passthrough` **deliberately** (renderer escape hatch) and the `responsive` tombstone (#4876) is untouched. ⚠️ **The `compareTo` union caveat this row carried is RESOLVED, and it is the one entry in this table whose limit was dissolved rather than worked around.** 批 14 recorded that `compareTo` was a UNION, so its curated prescription was produced but never delivered — `zodIssuesToFields` maps only top-level issues and a failed union collapses to a bare `Invalid input` (#5014) — with the rejection itself unaffected. **#5011 removed the union**: the slot converged onto the analytics executor's own contract, `{ kind, dimension? }`, a plain strict object whose message IS top-level. The reason was not the message, it was worse — all three declared arms were broken on the ADR-0021 dataset path (the two strings silently dropped by the renderer, `{ offset }` throwing `compareTo requires a timeDimension "undefined"`), while all three worked on the legacy inline path: same key, two fates, the failing one blessed. The union-free shape is the design benefit, pinned in `dashboard-compareto.test.ts` so it cannot silently return. **#5014 still binds every OTHER curated message this campaign has put inside a union arm** — this row is one slot's correction, not the finding's retraction. ⚠️ **#5010 retired four more widget keys and moved this row's posture by nothing, which is the point.** The `#4956` drill gave `DashboardWidgetSchema`'s 22 widget-level keys their first per-key verdicts and found six dead; `actionUrl`/`actionType`/`actionIcon` (a per-widget action BUTTON no renderer in either repo has ever drawn — all 14 `actionUrl` reads in `DashboardRenderer` are scoped to `header.actions[]`) and `aria` (ARIA attributes that never reached the DOM — the dashboard-level `aria` the #3896 sweep removed, one level down) are now `retiredKey` tombstones beside `responsive`. **Strip sites remain 0 and the strictness verdict is untouched**, because a retirement is ADR-0049 work and this ratchet is not: closing a door makes a *dropped* key loud, it cannot make a *declared* one live — the same boundary `theme.zod.ts` records two rows up, met here from the other side. The removal also settled a second-order cost the strictness campaign could never have reached: `packages/lint`'s dashboard action-ref rule enforced ERROR-severity reference integrity on `widgets[].actionUrl`, its docblock calling the key "the per-widget button" and claiming to mirror a runtime dispatch that does not exist, so an author could FAIL A BUILD because a control that cannot render pointed at an action that also did not — an enforcement gate sustaining the very false affordance ADR-0049 wrote it to delete. That widget branch is gone, pinned. ⚠️ **`colorVariant`, the fifth dead key, is deliberately NOT retired here and this row must not be read as closing it**: the rewrite target the #4956 triage assumed (`options.colorVariant`) measured dead too — `options` only reaches a renderer through `componentSchema` on the INLINE path, and `dataset` is required on this schema, so every spec-authorable widget is dataset-bound and renders through `DatasetWidget`, which has no colour affordance at all. Moving the key there would relocate 16 authored sites from one dead slot to another and mint a second inert key. Returned for adjudication; `chartConfig`'s dashboard-face inertness (11 of 12 keys, #5175) is the same shape on the neighbouring slot | diff --git a/packages/spec/api-surface/ui.json b/packages/spec/api-surface/ui.json index 21aec6a2753..929a8063a33 100644 --- a/packages/spec/api-surface/ui.json +++ b/packages/spec/api-surface/ui.json @@ -80,6 +80,9 @@ "BulkActionOperationSchema (const)", "BulkActionParam (type)", "BulkActionParamSchema (const)", + "BulkActionResult (type)", + "BulkActionResultParsed (type)", + "BulkActionResultSchema (const)", "CHART_AGGREGATE_COMPARISON_SUFFIX (const)", "COLUMN_SUMMARY_AGGREGATION (const)", "COMPILED_PAGE_KINDS (const)", diff --git a/packages/spec/authorable-surface/ui.json b/packages/spec/authorable-surface/ui.json index e6f5da68ed5..4adf3548c7a 100644 --- a/packages/spec/authorable-surface/ui.json +++ b/packages/spec/authorable-surface/ui.json @@ -235,6 +235,8 @@ "ui/BulkActionParam:placeholder", "ui/BulkActionParam:required", "ui/BulkActionParam:type", + "ui/BulkActionResult:failed", + "ui/BulkActionResult:succeeded", "ui/CalendarConfig:allDayField", "ui/CalendarConfig:colorField", "ui/CalendarConfig:endDateField", diff --git a/packages/spec/declaration-map/ui.json b/packages/spec/declaration-map/ui.json index 9018e8bf3c2..2a31b911e0a 100644 --- a/packages/spec/declaration-map/ui.json +++ b/packages/spec/declaration-map/ui.json @@ -45,6 +45,8 @@ "BulkActionOperationSchema": "ui/BulkActionOperation", "BulkActionParam": "ui/BulkActionParam", "BulkActionParamSchema": "ui/BulkActionParam", + "BulkActionResult": "ui/BulkActionResult", + "BulkActionResultSchema": "ui/BulkActionResult", "CalendarConfig": "ui/CalendarConfig", "CalendarConfigSchema": "ui/CalendarConfig", "ChartAggregate": "ui/ChartAggregate", diff --git a/packages/spec/export-origins/ui.json b/packages/spec/export-origins/ui.json index b97d69624b1..f7675b375c4 100644 --- a/packages/spec/export-origins/ui.json +++ b/packages/spec/export-origins/ui.json @@ -77,6 +77,9 @@ "BulkActionOperationSchema": "src/ui/bulk-action.zod.ts#BulkActionOperationSchema (const)", "BulkActionParam": "src/ui/bulk-action.zod.ts#BulkActionParam (type)", "BulkActionParamSchema": "src/ui/bulk-action.zod.ts#BulkActionParamSchema (const)", + "BulkActionResult": "src/ui/bulk-action.zod.ts#BulkActionResult (type)", + "BulkActionResultParsed": "src/ui/bulk-action.zod.ts#BulkActionResultParsed (type)", + "BulkActionResultSchema": "src/ui/bulk-action.zod.ts#BulkActionResultSchema (const)", "CHART_AGGREGATE_COMPARISON_SUFFIX": "src/ui/chart-aggregate.ts#CHART_AGGREGATE_COMPARISON_SUFFIX (const)", "COLUMN_SUMMARY_AGGREGATION": "src/ui/view-grouping-query.ts#COLUMN_SUMMARY_AGGREGATION (const)", "COMPILED_PAGE_KINDS": "src/ui/page.zod.ts#COMPILED_PAGE_KINDS (const)", diff --git a/packages/spec/json-schema.manifest/ui.json b/packages/spec/json-schema.manifest/ui.json index 29823d3901f..a8f2ad41ff1 100644 --- a/packages/spec/json-schema.manifest/ui.json +++ b/packages/spec/json-schema.manifest/ui.json @@ -24,6 +24,7 @@ "ui/BulkActionExecution", "ui/BulkActionOperation", "ui/BulkActionParam", + "ui/BulkActionResult", "ui/CalendarConfig", "ui/ChartAggregate", "ui/ChartAggregateFunction", diff --git a/packages/spec/src/ui/bulk-action.test.ts b/packages/spec/src/ui/bulk-action.test.ts index bf7db305a8e..c34576de7a7 100644 --- a/packages/spec/src/ui/bulk-action.test.ts +++ b/packages/spec/src/ui/bulk-action.test.ts @@ -1,7 +1,7 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. import { describe, it, expect } from 'vitest'; -import { BulkActionDefSchema, BulkActionParamSchema } from './bulk-action.zod'; +import { BulkActionDefSchema, BulkActionParamSchema, BulkActionResultSchema } from './bulk-action.zod'; import { FieldSchema } from '../data/field.zod'; import { formatZodError } from '../shared/error-map.zod'; @@ -440,3 +440,101 @@ describe('BulkActionDefSchema — the def shape is typed, not `z.any()`', () => }); }); }); + +describe('BulkActionResultSchema — the per-row outcome an aggregate handler may resolve with', () => { + const parse = (value: unknown) => BulkActionResultSchema.safeParse(value); + const paths = (value: unknown): string[] => { + const r = parse(value); + return r.success ? [] : r.error.issues.map((i) => `${i.path.join('.')}:${i.code}`); + }; + + describe('— accepts', () => { + it('the full shape: rows written and rows refused, each refusal with its own reason', () => { + const r = parse({ succeeded: ['opp_1', 'opp_3'], failed: [{ id: 'opp_2', message: 'Plan B is Closed Won and was not moved.' }] }); + expect(r.success).toBe(true); + expect(r.data).toEqual({ succeeded: ['opp_1', 'opp_3'], failed: [{ id: 'opp_2', message: 'Plan B is Closed Won and was not moved.' }] }); + }); + + it('empty lists: a run that wrote every row, and one that wrote none', () => { + expect(parse({ succeeded: ['opp_1', 'opp_2'], failed: [] }).success).toBe(true); + expect(parse({ succeeded: [], failed: [{ id: 'opp_1', message: 'locked' }] }).success).toBe(true); + expect(parse({ succeeded: [], failed: [] }).success).toBe(true); + }); + + it('members beyond the two lists, kept as written and given no meaning (a handler may return a summary too)', () => { + const value = { succeeded: ['opp_1'], failed: [], summary: '1 opportunity moved', failed_total: 0 }; + const r = parse(value); + expect(r.success).toBe(true); + expect(r.data).toEqual(value); + }); + }); + + describe('— refuses', () => { + it('a non-string id, in either list', () => { + expect(paths({ succeeded: [42], failed: [] })).toEqual(['succeeded.0:invalid_type']); + expect(paths({ succeeded: [], failed: [{ id: 7, message: 'locked' }] })).toEqual(['failed.0.id:invalid_type']); + }); + + it('a `failed` entry without its `message`', () => { + expect(paths({ succeeded: [], failed: [{ id: 'opp_2' }] })).toEqual(['failed.0.message:invalid_type']); + }); + + it('a value missing either list (the planned reader reports it as unreadable, never as full success)', () => { + expect(paths({ succeeded: ['opp_1'] })).toEqual(['failed:invalid_type']); + expect(paths({ failed: [] })).toEqual(['succeeded:invalid_type']); + }); + + it('the neighbouring shapes: the data plane\'s batch counts and the console\'s BulkWriteResult', () => { + // `BatchUpdateResponseSchema` spells `succeeded` / `failed` as COUNTS with + // the rows under `results`; `BulkWriteResult` names failures + // `errors[].error`. Neither is this shape, and neither may parse as it. + expect(paths({ success: false, total: 2, succeeded: 1, failed: 1, results: [{ id: 'opp_1', success: true, index: 0 }] })) + .toEqual(['succeeded:invalid_type', 'failed:invalid_type']); + expect(paths({ succeeded: 1, errors: [{ id: 'opp_2', error: 'locked' }] })) + .toEqual(['succeeded:invalid_type', 'failed:invalid_type']); + expect(paths({ succeeded: ['opp_1'], failed: [{ id: 'opp_2', error: 'locked' }] })) + .toEqual(['failed.0.message:invalid_type']); + }); + }); + + describe('— the counting rules are the reader\'s, so the shape admits what they resolve', () => { + it('a duplicate id and an id in both lists parse; the planned reader counts the duplicate once and the overlap as failed', () => { + expect(parse({ succeeded: ['opp_1', 'opp_1', 'opp_2'], failed: [{ id: 'opp_2', message: 'locked' }] }).success).toBe(true); + }); + }); + + describe('— CONTROL: no per-row result keeps the one-outcome report', () => { + // The shape is optional. A handler that resolves with nothing, or with a + // value of its own, is not a per-row result, so the reader falls back to + // the one-outcome report it gives today. Nothing about the action or the + // def changes for it: the aggregate def still parses as it always did. + it('nothing, null, or a value of the handler\'s own is not a per-row result', () => { + for (const value of [undefined, null, true, 3, 'done', [], { ok: true }, { summary: 'all moved' }]) { + expect(parse(value).success).toBe(false); + } + }); + + it('an aggregate def declares no result and parses as before', () => { + expect(BulkActionDefSchema.safeParse({ name: 'showcase_recalc_selection', operation: 'custom', execution: 'aggregate' }).success).toBe(true); + }); + }); + + describe('— a rejection stays the one-outcome report (documents the ruling; not coverage: no reader exists yet)', () => { + // The result travels as the RESOLVE value only. A rejection reaches the + // console as the ADR-0112 refusal envelope, and the `/actions` door + // carries no structured body on a script or flow arm's throw, so a + // rejection is one outcome for the selection: the envelope is not a + // per-row result, even when a handler tried to attach one inside it. + it('the refusal envelope is not a per-row result', () => { + expect(parse({ success: false, error: { code: 'HOOK_ABORTED', message: 'Plan B is Closed Won' } }).success).toBe(false); + }); + + it('nor is an envelope that carries the shape inside its error', () => { + const attached = { + success: false, + error: { code: 'HOOK_ABORTED', message: 'Plan B is Closed Won', details: { succeeded: ['opp_1'], failed: [{ id: 'opp_2', message: 'locked' }] } }, + }; + expect(parse(attached).success).toBe(false); + }); + }); +}); diff --git a/packages/spec/src/ui/bulk-action.zod.ts b/packages/spec/src/ui/bulk-action.zod.ts index 9a7277590f3..09291dc0c8a 100644 --- a/packages/spec/src/ui/bulk-action.zod.ts +++ b/packages/spec/src/ui/bulk-action.zod.ts @@ -120,6 +120,85 @@ export type BulkActionOperation = z.input; export const BulkActionExecutionSchema = z.enum(['perRecord', 'aggregate']); export type BulkActionExecution = z.input; +/** + * The per-row outcome an `execution: 'aggregate'` handler MAY resolve with + * (#34216, seat ruling 6905490575, option A). + * + * **[PLANNED — not enforced]** Declared ahead of its reader. The console does + * NOT read this value yet: the grid's bulk reader is #34269. Until that lands + * the grid counts a resolved aggregate call as covering the whole selection, + * so a handler that cannot cover the whole selection must still REJECT. A + * handler that resolves with `failed` rows today is reported as full success. + * + * An aggregate dispatch is ONE call carrying the whole selection in + * `params._selectedIds`, so the call's own success or failure is one outcome + * for N rows. A handler that writes row by row can move some rows and fail on + * others; without a declared answer the console can only say "not all + * completed", never which rows changed. This is that answer. + * + * **Resolve value only — never a rejection.** The object IS the handler's + * whole resolve value (no wrapper key). Once the reader (#34269) lands, a run + * that moved some rows and refused others resolves with it, a non-empty + * `failed` being a legal success answer. A rejection keeps meaning "the + * handler could not produce an outcome" and stays the one-outcome report: the + * `/actions` door carries no structured body on a script or flow arm's throw + * (the shared resolver's `details` is a closed list, and the sandbox passes + * only `code`, `fields`, `status` and `userMessage` out of a body), so a + * per-row result attached to a throw would be dropped. + * + * **Not `BatchUpdateResponse`, and not `BulkWriteResult`.** The data plane's + * batch answer (`BatchUpdateResponseSchema`, `api/batch.zod.ts`) spells + * `succeeded` / `failed` as COUNTS and puts the rows under `results`, and the + * console's `BulkWriteResult` names its failures `errors[].error`. Here + * `succeeded` and `failed` are the row LISTS themselves and a failure's reason + * is `message`. A value shaped like either neighbour does not parse. + * + * **How the reader (#34269) will read it** — only on an + * `execution: 'aggregate'` dispatch: + * - A value with NEITHER a `succeeded` nor a `failed` member (nothing, a + * summary, an artifact link) keeps the one-outcome report: the shape is + * optional. + * - A value that carries `succeeded` or `failed` but does not parse is + * reported as an UNREADABLE result, never as full success. + * - Members beyond the two lists are tolerated (`looseObject`, a wire shape + * written by a handler, not by an author) and carry no meaning, so a + * handler may return a summary beside them. + * + * **How the reader (#34269) will count ids.** Every id must be one of the + * dispatched `params._selectedIds`: + * - an id outside the selection is a handler bug: dropped, counted nowhere; + * - a duplicate id counts once; + * - an id in BOTH lists counts as failed; + * - a selected id in NEITHER list is reported as not confirmed, never as + * succeeded. + */ +export const BulkActionResultSchema = lazySchema(() => z.looseObject({ + succeeded: z.array(z.string()).describe( + '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.', + ), + failed: z.array(z.looseObject({ + id: z.string().describe('Id of a selected row the handler did not write: one of the dispatched `params._selectedIds`.'), + message: z.string().describe('Why this row was not written, as the person running the action should read it.'), + })).describe( + '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.', + ), +}).describe( + '[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.', +)); +export type BulkActionResult = z.input; +/** Post-parse shape of {@link BulkActionResult} — defaults applied, transforms run (ADR-0122). */ +export type BulkActionResultParsed = z.infer; + /** * Keys a widget on this path really reads off the field bag — and which this * shape nevertheless does NOT declare, so their rejection has to carry the