From 7f290c53d425ba08882c77d6a1352c402d8b3358 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:00:22 +0000 Subject: [PATCH 1/6] feat(spec): the action answer's field formats gain table, with its columns `table` draws an array of objects as rows, one cell per entry of the field row's new `columns`. Refused: `columns` beside any other format, `table` without `columns`, `table` as a cell format and as the dialog-level default. Claude-Session: https://claude.ai/code/session_01ADHkmRAxMkAHLvWYP3eojs Co-authored-by: Claude --- .../src/ui/action-answer-table-format.test.ts | 163 ++++++++++++++++++ packages/spec/src/ui/action-preflight.test.ts | 2 +- packages/spec/src/ui/action.zod.ts | 112 +++++++++++- 3 files changed, 269 insertions(+), 8 deletions(-) create mode 100644 packages/spec/src/ui/action-answer-table-format.test.ts diff --git a/packages/spec/src/ui/action-answer-table-format.test.ts b/packages/spec/src/ui/action-answer-table-format.test.ts new file mode 100644 index 00000000000..8450709c8bb --- /dev/null +++ b/packages/spec/src/ui/action-answer-table-format.test.ts @@ -0,0 +1,163 @@ +// Copyright (c) 2026 ObjectStack contributors. Apache-2.0 license. +// +// objectstack#34391 — the action answer's field formats gain `table`, with the +// field row's `columns`. One row builder serves `resultDialog.fields` and +// `preflight.fields`, so every pin here runs at both surfaces. +// +// Refusals are asserted on the issue envelope (code + path) and on the first +// clause of the message, never the full prose. The CONTROL block holds every +// pre-existing format and row parsing unchanged. + +import { describe, it, expect } from 'vitest'; +import { ActionSchema } from './action.zod'; + +const PRE_EXISTING_FORMATS = ['qrcode', 'code-list', 'secret', 'text', 'json'] as const; + +const resultDialogAction = (resultDialog: Record) => ({ + name: 'add_people', + label: 'Add people', + type: 'api', + target: '/api/v1/x/add-people', + resultDialog, +}); + +const preflightAction = (fields: unknown[]) => ({ + name: 'import_people', + label: 'Import people', + type: 'api', + target: '/api/v1/x/import', + params: [{ name: 'file_id', type: 'text', required: true }], + preflight: { read: { url: '/api/v1/x/import-plan?file=${param.file_id}' }, path: 'data', fields }, +}); + +/** The two surfaces built from the one row, each with the issue-path prefix of its `fields`. */ +const SURFACES = [ + ['resultDialog.fields', (fields: unknown[]) => resultDialogAction({ fields })], + ['preflight.fields', (fields: unknown[]) => preflightAction(fields)], +] as const; + +type Issue = { path: PropertyKey[]; code: string; message: string }; +const issuesOf = (value: unknown): Issue[] => { + const r = ActionSchema.safeParse(value); + return r.success ? [] : (r.error.issues as Issue[]); +}; +const issuesAt = (value: unknown, path: string): Issue[] => + issuesOf(value).filter((i) => i.path.join('.') === path); + +const table = { + path: 'rows', + label: 'Result per person', + format: 'table', + columns: [ + { path: 'email', label: 'Email' }, + { path: 'outcome', format: 'text' }, + { path: 'refusal.reason', label: { en: 'Reason', 'zh-CN': '原因' } }, + ], +}; + +describe('CONTROL — every pre-existing format and row parses unchanged', () => { + describe.each(SURFACES)('%s', (_prefix, build) => { + it.each(PRE_EXISTING_FORMATS)('`format: %j` on a field parses, the row kept as written', (format) => { + const row = { path: 'value', label: 'Value', format }; + const r = ActionSchema.safeParse(build([row])); + expect(r.success, JSON.stringify(r.error?.issues)).toBe(true); + }); + + it('a row with only `path` parses', () => { + expect(issuesOf(build([{ path: 'value' }]))).toEqual([]); + }); + + it('the row still refuses an unknown key, an unknown format, and answers its aliases', () => { + expect(issuesAt(build([{ key: 'value' }]), `${_prefix}.0`).map((i) => i.code)).toEqual(['unrecognized_keys']); + expect(issuesAt(build([{ key: 'value' }]), `${_prefix}.0`)[0].message).toContain('path'); + expect(issuesAt(build([{ path: 'v', format: 'chart' }]), `${_prefix}.0.format`).map((i) => i.code)) + .toEqual(['invalid_value']); + }); + }); + + it.each(PRE_EXISTING_FORMATS)('`resultDialog.format: %j` still parses as the dialog-level default', (format) => { + expect(issuesOf(resultDialogAction({ format, fields: [{ path: 'value' }] }))).toEqual([]); + }); +}); + +describe('`format: \'table\'` with `columns` — the widening', () => { + it.each(SURFACES)('parses on %s, and the row is kept as written', (prefix, build) => { + const r = ActionSchema.safeParse(build([table])); + expect(r.success, JSON.stringify(r.error?.issues)).toBe(true); + const parsed = r.success ? r.data : undefined; + const rows = prefix.startsWith('resultDialog') ? parsed?.resultDialog?.fields : parsed?.preflight?.fields; + expect(rows).toEqual([table]); + }); + + it.each(PRE_EXISTING_FORMATS)('a cell takes `format: %j` (the field set minus `table`)', (format) => { + const row = { ...table, columns: [{ path: 'email', format }] }; + for (const [, build] of SURFACES) expect(issuesOf(build([row]))).toEqual([]); + }); + + it('a column answers the row\'s aliases where they apply (`key`/`field`/`name` → path, `title` → label, `display`/`render` → format)', () => { + for (const [prefix, build] of SURFACES) { + for (const [alias, canonical] of [ + ['key', 'path'], ['field', 'path'], ['name', 'path'], ['title', 'label'], ['display', 'format'], ['render', 'format'], + ] as const) { + const column = { path: 'email', [alias]: alias === 'display' || alias === 'render' ? 'text' : 'x' }; + const issues = issuesAt(build([{ ...table, columns: [column] }]), `${prefix}.0.columns.0`); + expect(issues.map((i) => i.code), `${prefix} ${alias}`).toEqual(['unrecognized_keys']); + expect(issues[0].message, `${prefix} ${alias}`).toContain(`\`${canonical}\``); + } + } + }); +}); + +describe('refusal 1 — `columns` beside a format other than `table`', () => { + describe.each(SURFACES)('%s', (prefix, build) => { + it.each(PRE_EXISTING_FORMATS)('refuses `columns` beside `format: %j`', (format) => { + const issues = issuesAt(build([{ path: 'rows', format, columns: table.columns }]), `${prefix}.0.columns`); + expect(issues.map((i) => i.code)).toEqual(['custom']); + expect(issues[0].message).toMatch(/^`columns` lists the cells of a `format: 'table'` field/); + expect(issues[0].message).toContain(`\`${format}\``); + }); + + it('refuses `columns` on a field with no `format` (the dialog-level default is never `table`)', () => { + const issues = issuesAt(build([{ path: 'rows', columns: table.columns }]), `${prefix}.0.columns`); + expect(issues.map((i) => i.code)).toEqual(['custom']); + expect(issues[0].message).toContain('the dialog-level default is never `table`'); + }); + }); +}); + +describe('refusal 2 — `format: \'table\'` without `columns` (refused, never defaulted to the element\'s keys)', () => { + describe.each(SURFACES)('%s', (prefix, build) => { + it.each([ + ['omitted', undefined], + ['empty', []], + ])('refuses `columns` %s', (_label, columns) => { + const row = columns === undefined ? { path: 'rows', format: 'table' } : { path: 'rows', format: 'table', columns }; + const issues = issuesAt(build([row]), `${prefix}.0.columns`); + expect(issues.map((i) => i.code)).toEqual(['custom']); + expect(issues[0].message).toMatch(/^`format: 'table'` draws each element of the array at `path` as one row/); + }); + }); +}); + +describe('refusal 3 — a nested `table` in a column', () => { + it.each(SURFACES)('refuses a cell `format: \'table\'` on %s, by name', (prefix, build) => { + const row = { ...table, columns: [{ path: 'children', format: 'table' }] }; + const issues = issuesAt(build([row]), `${prefix}.0.columns.0.format`); + expect(issues.map((i) => i.code)).toEqual(['invalid_value']); + expect(issues[0].message).toMatch(/^`table` is a field format, not a cell format/); + }); +}); + +describe('R3 — the dialog-level `format` takes every field format but `table`', () => { + it('refuses `resultDialog.format: \'table\'` by name', () => { + const issues = issuesAt(resultDialogAction({ format: 'table', fields: [{ path: 'value' }] }), 'resultDialog.format'); + expect(issues.map((i) => i.code)).toEqual(['invalid_value']); + expect(issues[0].message).toMatch(/^`table` is a per-field format only/); + }); + + it('an unknown dialog-level format keeps the generic enum refusal', () => { + const issues = issuesAt(resultDialogAction({ format: 'chart' }), 'resultDialog.format'); + expect(issues.map((i) => i.code)).toEqual(['invalid_value']); + expect(issues[0].message).not.toContain('per-field format only'); + }); +}); diff --git a/packages/spec/src/ui/action-preflight.test.ts b/packages/spec/src/ui/action-preflight.test.ts index 575b2c153c4..dbf38796ae8 100644 --- a/packages/spec/src/ui/action-preflight.test.ts +++ b/packages/spec/src/ui/action-preflight.test.ts @@ -163,7 +163,7 @@ describe('refusal 3 — a credential-shaped or unknown key', () => { const alias = issuesAt(withPreflight({ fields: [{ key: 'findings' }] }), 'preflight.fields.0'); expect(alias.map((i) => i.code)).toEqual(['unrecognized_keys']); expect(alias[0].message).toContain('path'); - const format = issuesAt(withPreflight({ fields: [{ path: 'findings', format: 'table' }] }), 'preflight.fields.0.format'); + const format = issuesAt(withPreflight({ fields: [{ path: 'findings', format: 'chart' }] }), 'preflight.fields.0.format'); expect(format.map((i) => i.code)).toEqual(['invalid_value']); }); diff --git a/packages/spec/src/ui/action.zod.ts b/packages/spec/src/ui/action.zod.ts index 53ad0e809c0..f967a520381 100644 --- a/packages/spec/src/ui/action.zod.ts +++ b/packages/spec/src/ui/action.zod.ts @@ -835,12 +835,93 @@ const ACTION_HISTORY = * and `preflight.fields` share, so the param dialog's preflight panel and the * one-shot result dialog draw from one vocabulary. The renderer contract of * each member is on `resultDialog`. + * + * `table` is a FIELD format only: it needs the field's own `columns`, so the + * dialog-level default and a column's cell take {@link actionAnswerScalarFormat}, + * the set derived from this one with `table` excluded (#34391). + */ +const ACTION_ANSWER_FIELD_FORMATS = ['qrcode', 'code-list', 'secret', 'text', 'json', 'table'] as const; + +const ActionAnswerFieldFormatSchema = z.enum(ACTION_ANSWER_FIELD_FORMATS); + +/** + * The field set minus `table`: the formats of `resultDialog.format` (a default + * carries no `columns`) and of a table column's cell (a table does not nest). + * Derived with `.exclude`, never a second hand-written list, so a format added + * to the field set reaches both. `subject` names the slot in the refusal. + */ +function actionAnswerScalarFormat(tableRefusal: string) { + return ActionAnswerFieldFormatSchema.exclude(['table'], { + error: (issue) => (issue.input === 'table' ? tableRefusal : undefined), + }); +} + +/** + * One column of a `table` field: a dot `path` into ONE element of the array, + * an optional header `label`, an optional cell `format`. It reuses the field + * row's alias map where it applies. */ -const ACTION_ANSWER_FIELD_FORMATS = ['qrcode', 'code-list', 'secret', 'text', 'json'] as const; +const ActionAnswerTableColumnSchema = strictObject({ + surface: 'this table column', + history: ACTION_HISTORY, + aliases: { key: 'path', field: 'path', name: 'path', title: 'label', display: 'format', render: 'format' }, +}, { + path: z.string().describe('Dot path into one element of the array (e.g. "email", "result.reason").'), + label: I18nLabelSchema.optional().describe('Column header. Omitted, the header is the column `path`.'), + format: actionAnswerScalarFormat( + '`table` is a field format, not a cell format: a cell draws one value of one row, and a table does not ' + + 'nest. Drop `format` (a cell whose value is an object or an array is drawn as compact JSON text), or ' + + "write `format: 'json'`.", + ).optional().describe('Cell format: the field formats minus `table`. Omitted, a scalar draws as `text`; a value that is an object or an array draws as compact JSON text.'), +}); + +/** + * [#34391] The cross-key refusals of one answer row — `columns` belongs to + * `format: 'table'` and to nothing else, both ways round: + * + * 1. `columns` beside any other `format` (or none — the dialog-level default + * is never `table`) would parse clean and never be read. + * 2. `format: 'table'` without `columns` is refused, NOT defaulted to the + * element's keys: the column list is the contract the console draws + * exactly, and guessing keys out of a JSON array is the consumer dialect + * Prime Directive 12 forbids. An empty list draws no column, so it is + * refused too. + */ +function refuseTableColumnContradictions( + row: { format?: string; columns?: unknown[] }, + ctx: z.core.$RefinementCtx, +): void { + if (row.format === 'table') { + if (row.columns === undefined || row.columns.length === 0) { + ctx.addIssue({ + code: 'custom', + path: ['columns'], + message: + "`format: 'table'` draws each element of the array at `path` as one row, and needs `columns` to " + + 'say which values of an element are its cells, in order: the console draws exactly the listed ' + + "columns and never guesses them from the element's keys. Add `columns: [{ path, label }]`, one " + + 'entry per cell.', + }); + } + return; + } + if (row.columns !== undefined) { + ctx.addIssue({ + code: 'custom', + path: ['columns'], + message: + "`columns` lists the cells of a `format: 'table'` field, and this field's format is " + + (row.format === undefined ? 'not `table` (the dialog-level default is never `table`)' : `\`${row.format}\``) + + ', so the list would parse clean and never be read. Write ' + + "`format: 'table'` on this field to draw the array as rows, or drop `columns`.", + }); + } +} /** * One row of the fields an action shows from a server answer: a dot `path` - * into the answer, an optional `label`, an optional `format` override. + * into the answer, an optional `label`, an optional `format` override, and — + * for `format: 'table'` only — its `columns`. * `resultDialog.fields` and `preflight.fields` are built from this one row * (#31840), so the row's keys, aliases and format set cannot drift between * them; each caller names its own surface and what `path` is read against. @@ -853,8 +934,9 @@ function actionAnswerFieldRow(surface: string, pathDescription: string) { }, { path: z.string().describe(pathDescription), label: I18nLabelSchema.optional(), - format: z.enum(ACTION_ANSWER_FIELD_FORMATS).optional().describe('Per-field format override.'), - }); + format: ActionAnswerFieldFormatSchema.optional().describe('Per-field format override.'), + columns: z.array(ActionAnswerTableColumnSchema).optional().describe("The cells of a `format: 'table'` field, in order — required by `table`, refused beside any other format."), + }).superRefine(refuseTableColumnContradictions); } export const ActionAiSchema = strictObject({ @@ -1722,6 +1804,18 @@ const actionObject = () => strictObject({ * toggle and copy button. * - `text` — plain text with copy. * - `json` — pretty-printed JSON in a monospace block. + * - `table` (#34391) — value must be an array; each element is one row and + * each entry of the field's `columns` one cell, in `columns` order. The + * header of a column is its `label`, falling back to its `path`. A cell + * reads the column's dot `path` in the element and draws in the column's + * `format` (omitted: a scalar as `text`); a cell whose value is an object + * or an array, and every cell of an element that is not an object, draws + * as compact JSON text. `[]` draws the header row over an empty-state + * line. A value that is missing is skipped like any other field's, and a + * value that is not an array draws as `json`, as `code-list` does. + * `table` is a field format only: it requires `columns` (never guessed + * from the element's keys), `columns` is refused beside any other format, + * and neither the dialog-level `format` nor a cell takes `table`. * * The dialog SHOULD set `refreshAfter` to true on close (separate from * the existing `refreshAfter` flag, which fires immediately on success). @@ -1734,11 +1828,15 @@ const actionObject = () => strictObject({ title: I18nLabelSchema.optional(), description: I18nLabelSchema.optional(), acknowledge: I18nLabelSchema.optional().describe('Acknowledge button label, e.g. "I have saved this"'), - format: z.enum(ACTION_ANSWER_FIELD_FORMATS).optional().describe('Default format for fields without their own format. Defaults to json when omitted.'), + format: actionAnswerScalarFormat( + "`table` is a per-field format only: the dialog-level `format` is the default for fields without " + + 'their own, and a default carries no `columns`. Write `format: \'table\'` with its `columns` on the ' + + 'field that holds the array.', + ).optional().describe('Default format for fields without their own format: any field format but `table`, which needs the field\'s own `columns`. Defaults to json when omitted.'), fields: z.array(actionAnswerFieldRow( 'this result dialog field', 'Dot path into result.data (e.g. "totpURI", "client.client_secret").', - )).optional().describe('Which fields from result.data to render. Omit to dump full JSON.'), + )).optional().describe('Which fields from result.data to render. Omit to dump full JSON. A field with `format: \'table\'` draws an array of objects as rows, one cell per entry of its `columns`, in order; the columns are never guessed from the elements\' keys.'), }).optional().describe('Render API response in a one-shot reveal dialog (suppresses successMessage when set).'), /** * [#31840] Preflight read — one same-origin `GET` the param dialog sends @@ -1852,7 +1950,7 @@ const actionObject = () => strictObject({ fields: z.array(actionAnswerFieldRow( 'this preflight field', 'Dot path into the selected answer (e.g. "findings", "verdict.summary").', - )).optional().describe('Which values of the selected answer the panel shows, in `resultDialog.fields`\' row and format set. Omit to show the selected answer as JSON.'), + )).optional().describe('Which values of the selected answer the panel shows, in `resultDialog.fields`\' row and format set — `table` and its `columns` included, drawn by the same renderer contract. Omit to show the selected answer as JSON.'), seed: z.array(strictObject({ surface: 'this preflight seed', history: ACTION_HISTORY, From 766073740dc29a8fe07adcddfb9aff3b273080d0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:11:11 +0000 Subject: [PATCH 2/6] chore(spec): regenerate the outputs the table format moves, and its changeset Ledger rows for the new row refinement (24 dropped-refinement sites), the `columns` liveness rows graded planned until the console renderer lands, the reference page, the strictness counts, and a minor changeset. Claude-Session: https://claude.ai/code/session_01ADHkmRAxMkAHLvWYP3eojs Co-authored-by: Claude --- .../34391-action-answer-table-format.md | 20 ++++++++++++ content/docs/references/ui/action.mdx | 6 ++-- .../ui.md | 10 +++--- .../spec/dropped-refinements.baseline.json | 32 ++++++++++++++++--- packages/spec/liveness/action.json | 24 +++++++++++++- packages/spec/liveness/state-counts/action.md | 2 +- packages/spec/src/ui/action.zod.ts | 2 +- 7 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 .changeset/34391-action-answer-table-format.md diff --git a/.changeset/34391-action-answer-table-format.md b/.changeset/34391-action-answer-table-format.md new file mode 100644 index 00000000000..48fae5360fd --- /dev/null +++ b/.changeset/34391-action-answer-table-format.md @@ -0,0 +1,20 @@ +--- +'@objectstack/spec': minor +--- + +feat(spec): an action's answer fields gain a `table` format, so a per-row answer is drawn as rows, not raw JSON + +Clause-②: yes (widening) — `format: 'table'` joins the field formats of `resultDialog.fields` and `preflight.fields`, and the field row gains `columns`; the only new refusals fall on the new value and the new key, and every action that parsed before still parses unchanged +Metadata-protocol: added + +An action whose server answers a list of rows (adding several people, importing a CSV) can now say how to show it. A field in `resultDialog.fields` (or `preflight.fields`, which shares the row) takes `format: 'table'` with `columns`, one entry per cell: `{ path, label?, format? }`, where `path` is read in one element of the array. + +**FROM → TO.** FROM: the answer's list could only be shown as a JSON block (`format: 'json'`). TO: `{ path: 'rows', format: 'table', columns: [{ path: 'email', label: 'Email' }, { path: 'reason', label: 'Reason' }] }` draws one row per element, one cell per column, in `columns` order, with the column `label` (or its `path`) as the header. + +Refused at parse, each with a message that names the fix: + +- `format: 'table'` without `columns`, or with an empty list. The columns are never guessed from the elements' keys. +- `columns` beside any other `format`, or on a field with no `format` (the dialog-level default is never `table`). +- `table` as a cell `format` (a table does not nest) and as the dialog-level `resultDialog.format` (a default carries no `columns`). + +The renderer contract is stated on `resultDialog`. The console's table renderer is still to come: until it lands, a `table` field draws its label alone, and `columns` is marked `[PLANNED — not yet rendered]`. diff --git a/content/docs/references/ui/action.mdx b/content/docs/references/ui/action.mdx index ad0664bf7b9..9aa080fcd97 100644 --- a/content/docs/references/ui/action.mdx +++ b/content/docs/references/ui/action.mdx @@ -167,8 +167,8 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities | **title** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | | **description** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | | **acknowledge** | `string \| Record` | optional | Acknowledge button label, e.g. "I have saved this" | -| **format** | `Enum<'qrcode' \| 'code-list' \| 'secret' \| 'text' \| 'json'>` | optional | Default format for fields without their own format. Defaults to json when omitted. | -| **fields** | `{ path: string; label?: string \| Record; format?: Enum<'qrcode' \| 'code-list' \| 'secret' \| 'text' \| 'json'> }[]` | optional | Which fields from result.data to render. Omit to dump full JSON. | +| **format** | `Enum<'qrcode' \| 'code-list' \| 'secret' \| 'text' \| 'json'>` | optional | Default format for fields without their own format: any field format but `table`, which needs the field's own `columns`. Defaults to json when omitted. | +| **fields** | `{ path: string; label?: string \| Record; format?: Enum<'qrcode' \| 'code-list' \| 'secret' \| 'text' \| 'json' \| 'table'>; columns?: object[] }[]` | optional | Which fields from result.data to render. Omit to dump full JSON. A field with `format: 'table'` draws an array of objects as rows, one cell per entry of its `columns`, in order; the columns are never guessed from the elements' keys. | ### Nested Shape: `Action.preflight` @@ -176,7 +176,7 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities | :--- | :--- | :--- | :--- | | **read** | `{ url: string; method?: 'GET' }` | ✅ | The read request — the same-origin endpoint the preflight reads | | **path** | `string` | optional | Dotted path selecting the sub-tree of the answer the preflight shows and seeds from, e.g. `data` in a `{ success, data }` envelope; omitted, the whole answer | -| **fields** | `{ path: string; label?: string \| Record; format?: Enum<'qrcode' \| 'code-list' \| 'secret' \| 'text' \| 'json'> }[]` | optional | Which values of the selected answer the panel shows, in `resultDialog.fields`' row and format set. Omit to show the selected answer as JSON. | +| **fields** | `{ path: string; label?: string \| Record; format?: Enum<'qrcode' \| 'code-list' \| 'secret' \| 'text' \| 'json' \| 'table'>; columns?: object[] }[]` | optional | Which values of the selected answer the panel shows, in `resultDialog.fields`' row and format set — `table` and its `columns` included, drawn by the same renderer contract. Omit to show the selected answer as JSON. | | **seed** | `{ param: string; path: string }[]` | optional | Answer-to-param seeding: each entry writes the value at `path` in the selected answer into the named param, which the dialog draws read-only and submits as shown. Each param is seeded once. | ### Nested Shape: `Action.ai` 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..185f4de2f7a 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/` | 222 | 213 | 4 | 0 | 5 | ## `ui/` — sites @@ -32,7 +32,7 @@ classify and is not listed (it becomes reportable the day it grows its first sit | File | Sites | |---|---| | `action-params.zod.ts` | 1 | -| `action.zod.ts` | 12 | +| `action.zod.ts` | 13 | | `app.zod.ts` | 20 | | `bulk-action.zod.ts` | 4 | | `chart.zod.ts` | 8 | @@ -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** | **222** | ## `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 222**, 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** | **222** | | Bucket | Sites | |---|---| diff --git a/packages/spec/dropped-refinements.baseline.json b/packages/spec/dropped-refinements.baseline.json index 707a851edf6..bd7aa11805a 100644 --- a/packages/spec/dropped-refinements.baseline.json +++ b/packages/spec/dropped-refinements.baseline.json @@ -3,7 +3,7 @@ "measured": { "zod": "4.4.3", "publishedSchemasWithDroppedRefinements": 266, - "droppedRefinementSites": 1090, + "droppedRefinementSites": 1114, "refinementSitesThatDidProject": 728, "refinementSitesWithNoJsonFormToCompare": 0 }, @@ -105,6 +105,8 @@ "manifest.actions.element.in.ai.outputSchema", "manifest.actions.element.in.onSuccess", "manifest.actions.element.in.params.element.in", + "manifest.actions.element.in.preflight.fields.element", + "manifest.actions.element.in.resultDialog.fields.element", "manifest.agents.element.memory", "manifest.agents.element.structuredOutput.schema", "manifest.analyticsCubes.element.measures.valueType", @@ -287,6 +289,8 @@ "data.options[1].manifest.actions.element.in.ai.outputSchema", "data.options[1].manifest.actions.element.in.onSuccess", "data.options[1].manifest.actions.element.in.params.element.in", + "data.options[1].manifest.actions.element.in.preflight.fields.element", + "data.options[1].manifest.actions.element.in.resultDialog.fields.element", "data.options[1].manifest.agents.element.memory", "data.options[1].manifest.agents.element.structuredOutput.schema", "data.options[1].manifest.analyticsCubes.element.measures.valueType", @@ -437,6 +441,8 @@ "options[1].manifest.actions.element.in.ai.outputSchema", "options[1].manifest.actions.element.in.onSuccess", "options[1].manifest.actions.element.in.params.element.in", + "options[1].manifest.actions.element.in.preflight.fields.element", + "options[1].manifest.actions.element.in.resultDialog.fields.element", "options[1].manifest.agents.element.memory", "options[1].manifest.agents.element.structuredOutput.schema", "options[1].manifest.analyticsCubes.element.measures.valueType", @@ -526,6 +532,8 @@ "data.packages.element.options[1].manifest.actions.element.in.ai.outputSchema", "data.packages.element.options[1].manifest.actions.element.in.onSuccess", "data.packages.element.options[1].manifest.actions.element.in.params.element.in", + "data.packages.element.options[1].manifest.actions.element.in.preflight.fields.element", + "data.packages.element.options[1].manifest.actions.element.in.resultDialog.fields.element", "data.packages.element.options[1].manifest.agents.element.memory", "data.packages.element.options[1].manifest.agents.element.structuredOutput.schema", "data.packages.element.options[1].manifest.analyticsCubes.element.measures.valueType", @@ -612,7 +620,9 @@ "data.actions.element.in", "data.actions.element.in.ai.outputSchema", "data.actions.element.in.onSuccess", - "data.actions.element.in.params.element.in" + "data.actions.element.in.params.element.in", + "data.actions.element.in.preflight.fields.element", + "data.actions.element.in.resultDialog.fields.element" ] }, "api/ObjectDefinitionResponse": { @@ -622,6 +632,8 @@ "data.actions.element.in.ai.outputSchema", "data.actions.element.in.onSuccess", "data.actions.element.in.params.element.in", + "data.actions.element.in.preflight.fields.element", + "data.actions.element.in.resultDialog.fields.element", "data.defaultRowScope", "data.fieldGroups", "data.fields.out.valueType", @@ -1125,6 +1137,8 @@ "actions.element.in.ai.outputSchema", "actions.element.in.onSuccess", "actions.element.in.params.element.in", + "actions.element.in.preflight.fields.element", + "actions.element.in.resultDialog.fields.element", "defaultRowScope", "fieldGroups", "fields.out.valueType", @@ -1364,7 +1378,9 @@ "actions.element.in", "actions.element.in.ai.outputSchema", "actions.element.in.onSuccess", - "actions.element.in.params.element.in" + "actions.element.in.params.element.in", + "actions.element.in.preflight.fields.element", + "actions.element.in.resultDialog.fields.element" ] }, "kernel/OpsDomainModule": { @@ -1488,6 +1504,8 @@ "operations.element.options[3].object.actions.element.in.ai.outputSchema", "operations.element.options[3].object.actions.element.in.onSuccess", "operations.element.options[3].object.actions.element.in.params.element.in", + "operations.element.options[3].object.actions.element.in.preflight.fields.element", + "operations.element.options[3].object.actions.element.in.resultDialog.fields.element", "operations.element.options[3].object.defaultRowScope", "operations.element.options[3].object.fieldGroups", "operations.element.options[3].object.fields.out.valueType", @@ -1512,6 +1530,8 @@ "object.actions.element.in.ai.outputSchema", "object.actions.element.in.onSuccess", "object.actions.element.in.params.element.in", + "object.actions.element.in.preflight.fields.element", + "object.actions.element.in.resultDialog.fields.element", "object.defaultRowScope", "object.fieldGroups", "object.fields.out.valueType", @@ -1568,6 +1588,8 @@ "options[3].object.actions.element.in.ai.outputSchema", "options[3].object.actions.element.in.onSuccess", "options[3].object.actions.element.in.params.element.in", + "options[3].object.actions.element.in.preflight.fields.element", + "options[3].object.actions.element.in.resultDialog.fields.element", "options[3].object.defaultRowScope", "options[3].object.fieldGroups", "options[3].object.fields.out.valueType", @@ -1703,7 +1725,9 @@ "in", "in.ai.outputSchema", "in.onSuccess", - "in.params.element.in" + "in.params.element.in", + "in.preflight.fields.element", + "in.resultDialog.fields.element" ] }, "ui/ActionAi": { diff --git a/packages/spec/liveness/action.json b/packages/spec/liveness/action.json index 60b1d988d07..b2b12c9b3d9 100644 --- a/packages/spec/liveness/action.json +++ b/packages/spec/liveness/action.json @@ -277,7 +277,7 @@ }, "resultDialog": { "status": "live", - "note": "objectui one-shot result reveal {title,description,acknowledge,format,fields}." + "note": "objectui one-shot result reveal {title,description,acknowledge,format,fields}. `fields[].format: 'table'` and its `columns` (#34391) are PLANNED until the console reader #33187 lands (see `preflight.fields.columns`, the same row): the spec refuses the contradictions at parse, and the console draws a `table` row's label alone today." }, "preflight": { "status": "live", @@ -325,6 +325,28 @@ "status": "live", "verifiedAt": "2026-11-09", "note": "Live with its container `preflight.fields`: the row's display format, from resultDialog's format set." + }, + "columns": { + "status": "planned", + "verifiedAt": "2026-11-16", + "note": "PLANNED (spec card #34391; reader #33187, maintainer ruling A 6915677641). The cells of a `format: 'table'` row, `[{ path, label?, format? }]`, from the row builder `resultDialog.fields` shares (packages/spec/src/ui/action.zod.ts#actionAnswerFieldRow). Enforced at parse today: required by `table`, refused beside any other format (#refuseTableColumnContradictions), and a cell takes the field formats minus `table`. NOT yet drawn: the console's `ResultField` (ui/packages/app-shell/src/views/ActionResultDialog.tsx) has no `table` branch, so until #33187 lands a `table` row draws its label alone. Re-grade `live` in the PR that lands that renderer.", + "children": { + "path": { + "status": "planned", + "verifiedAt": "2026-11-16", + "note": "Planned with its container `preflight.fields.columns`: the dot path, in ONE element of the array, of the value a cell draws." + }, + "label": { + "status": "planned", + "verifiedAt": "2026-11-16", + "note": "Planned with its container `preflight.fields.columns`: the column header; omitted, the header is the column's `path`." + }, + "format": { + "status": "planned", + "verifiedAt": "2026-11-16", + "note": "Planned with its container `preflight.fields.columns`: the cell format, the field formats minus `table` (refused at parse: a table does not nest); omitted, a scalar draws as `text` and an object or array as compact JSON text." + } + } } } }, diff --git a/packages/spec/liveness/state-counts/action.md b/packages/spec/liveness/state-counts/action.md index eb3f5b5f49a..5ab922ebcfd 100644 --- a/packages/spec/liveness/state-counts/action.md +++ b/packages/spec/liveness/state-counts/action.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `action` | 79 | 0 | 0 | 1 | 2 | 82 | +| `action` | 79 | 0 | 0 | 1 | 5 | 85 | diff --git a/packages/spec/src/ui/action.zod.ts b/packages/spec/src/ui/action.zod.ts index f967a520381..652f101d1bb 100644 --- a/packages/spec/src/ui/action.zod.ts +++ b/packages/spec/src/ui/action.zod.ts @@ -935,7 +935,7 @@ function actionAnswerFieldRow(surface: string, pathDescription: string) { path: z.string().describe(pathDescription), label: I18nLabelSchema.optional(), format: ActionAnswerFieldFormatSchema.optional().describe('Per-field format override.'), - columns: z.array(ActionAnswerTableColumnSchema).optional().describe("The cells of a `format: 'table'` field, in order — required by `table`, refused beside any other format."), + columns: z.array(ActionAnswerTableColumnSchema).optional().describe("[PLANNED — not yet rendered] The cells of a `format: 'table'` field, in order: `[{ path, label?, format? }]`, `path` read in ONE element of the array. Required by `table` (never guessed from the element's keys) and refused beside any other format. Until the console's table renderer lands, a `table` field draws its label alone."), }).superRefine(refuseTableColumnContradictions); } From 218118262e1528ad9ce10ea12e1d5fb6f8f5f12a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:23:02 +0000 Subject: [PATCH 3/6] fix(ui): the result dialog mirror derives its format members from the contract The two hand-written format unions refused the widened set where the action renderers forward `resultDialog` uncast; derive them like the label members beside them. Claude-Session: https://claude.ai/code/session_01ADHkmRAxMkAHLvWYP3eojs Co-authored-by: Claude --- .changeset/34391-action-answer-table-format.md | 3 +++ ui/packages/core/src/actions/ActionRunner.ts | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.changeset/34391-action-answer-table-format.md b/.changeset/34391-action-answer-table-format.md index 48fae5360fd..24d4bb4ae95 100644 --- a/.changeset/34391-action-answer-table-format.md +++ b/.changeset/34391-action-answer-table-format.md @@ -1,5 +1,6 @@ --- '@objectstack/spec': minor +'@object-ui/core': patch --- feat(spec): an action's answer fields gain a `table` format, so a per-row answer is drawn as rows, not raw JSON @@ -18,3 +19,5 @@ Refused at parse, each with a message that names the fix: - `table` as a cell `format` (a table does not nest) and as the dialog-level `resultDialog.format` (a default carries no `columns`). The renderer contract is stated on `resultDialog`. The console's table renderer is still to come: until it lands, a `table` field draws its label alone, and `columns` is marked `[PLANNED — not yet rendered]`. + +`@object-ui/core`: the `ResultDialogSpec` / `ResultDialogFieldSpec` `format` members now derive from the contract, as their label members already do, so the console's action renderers keep type-checking against the widened set. diff --git a/ui/packages/core/src/actions/ActionRunner.ts b/ui/packages/core/src/actions/ActionRunner.ts index a1964f8ff73..43ef8dcbb50 100644 --- a/ui/packages/core/src/actions/ActionRunner.ts +++ b/ui/packages/core/src/actions/ActionRunner.ts @@ -821,7 +821,8 @@ export interface ResultDialogFieldSpec { * and React refuses an object as a child. */ label?: SpecResultDialogField['label']; - format?: 'qrcode' | 'code-list' | 'secret' | 'text' | 'json'; + /** Derived, like `label`: the contract's field format set (`table` included). */ + format?: SpecResultDialogField['format']; } export interface ResultDialogSpec { /** Derived `I18nLabel` — see `ResultDialogFieldSpec.label` on resolving it. */ @@ -830,7 +831,8 @@ export interface ResultDialogSpec { description?: SpecResultDialog['description']; /** Derived `I18nLabel` — see `ResultDialogFieldSpec.label` on resolving it. */ acknowledge?: SpecResultDialog['acknowledge']; - format?: 'qrcode' | 'code-list' | 'secret' | 'text' | 'json'; + /** Derived: the dialog-level default set (every field format but `table`). */ + format?: SpecResultDialog['format']; fields?: ResultDialogFieldSpec[]; } From e735712d141de9bc7d7d18ee0883e2c4b2dfc994 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 23:20:12 +0000 Subject: [PATCH 4/6] docs(spec): one reading of the table cell rules, in the contract and the describes A cell draws its value in the column's format when it fits, and as compact JSON text otherwise, whatever the format; a missing value draws an empty cell; an element that is not an object draws itself in the first cell. Claude-Session: https://claude.ai/code/session_01ADHkmRAxMkAHLvWYP3eojs Co-authored-by: Claude --- packages/spec/liveness/action.json | 4 ++-- packages/spec/src/ui/action.zod.ts | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/spec/liveness/action.json b/packages/spec/liveness/action.json index b2b12c9b3d9..6e15ce14fdb 100644 --- a/packages/spec/liveness/action.json +++ b/packages/spec/liveness/action.json @@ -334,7 +334,7 @@ "path": { "status": "planned", "verifiedAt": "2026-11-16", - "note": "Planned with its container `preflight.fields.columns`: the dot path, in ONE element of the array, of the value a cell draws." + "note": "Planned with its container `preflight.fields.columns`: the dot path, in ONE element of the array, of the value a cell draws; a path that resolves to nothing draws an empty cell, and an element that is not an object draws as compact JSON text in its row's first cell." }, "label": { "status": "planned", @@ -344,7 +344,7 @@ "format": { "status": "planned", "verifiedAt": "2026-11-16", - "note": "Planned with its container `preflight.fields.columns`: the cell format, the field formats minus `table` (refused at parse: a table does not nest); omitted, a scalar draws as `text` and an object or array as compact JSON text." + "note": "Planned with its container `preflight.fields.columns`: the cell format, the field formats minus `table` (refused at parse: a table does not nest); omitted, `text`. A value that does not fit the cell's format, whatever it is, draws as compact JSON text, and a missing value draws an empty cell (the `table` bullet of the `resultDialog` renderer contract)." } } } diff --git a/packages/spec/src/ui/action.zod.ts b/packages/spec/src/ui/action.zod.ts index 652f101d1bb..18c781bd295 100644 --- a/packages/spec/src/ui/action.zod.ts +++ b/packages/spec/src/ui/action.zod.ts @@ -848,7 +848,8 @@ const ActionAnswerFieldFormatSchema = z.enum(ACTION_ANSWER_FIELD_FORMATS); * The field set minus `table`: the formats of `resultDialog.format` (a default * carries no `columns`) and of a table column's cell (a table does not nest). * Derived with `.exclude`, never a second hand-written list, so a format added - * to the field set reaches both. `subject` names the slot in the refusal. + * to the field set reaches both. `tableRefusal` is the message the slot answers + * for `table`; every other value keeps the generic enum refusal. */ function actionAnswerScalarFormat(tableRefusal: string) { return ActionAnswerFieldFormatSchema.exclude(['table'], { @@ -870,9 +871,9 @@ const ActionAnswerTableColumnSchema = strictObject({ label: I18nLabelSchema.optional().describe('Column header. Omitted, the header is the column `path`.'), format: actionAnswerScalarFormat( '`table` is a field format, not a cell format: a cell draws one value of one row, and a table does not ' - + 'nest. Drop `format` (a cell whose value is an object or an array is drawn as compact JSON text), or ' + + 'nest. Drop `format` (a cell value that does not fit its format, an object or an array included, draws as compact JSON text), or ' + "write `format: 'json'`.", - ).optional().describe('Cell format: the field formats minus `table`. Omitted, a scalar draws as `text`; a value that is an object or an array draws as compact JSON text.'), + ).optional().describe('Cell format: the field formats minus `table`; omitted, `text`. A value that does not fit the cell\'s format, whatever it is (an object or an array under `text`, a number under `secret`), draws as compact JSON text; a missing value draws an empty cell.'), }); /** @@ -934,7 +935,7 @@ function actionAnswerFieldRow(surface: string, pathDescription: string) { }, { path: z.string().describe(pathDescription), label: I18nLabelSchema.optional(), - format: ActionAnswerFieldFormatSchema.optional().describe('Per-field format override.'), + format: ActionAnswerFieldFormatSchema.optional().describe('Per-field format override. `table` [PLANNED — not yet rendered] draws an array as rows and requires `columns`.'), columns: z.array(ActionAnswerTableColumnSchema).optional().describe("[PLANNED — not yet rendered] The cells of a `format: 'table'` field, in order: `[{ path, label?, format? }]`, `path` read in ONE element of the array. Required by `table` (never guessed from the element's keys) and refused beside any other format. Until the console's table renderer lands, a `table` field draws its label alone."), }).superRefine(refuseTableColumnContradictions); } @@ -1807,12 +1808,19 @@ const actionObject = () => strictObject({ * - `table` (#34391) — value must be an array; each element is one row and * each entry of the field's `columns` one cell, in `columns` order. The * header of a column is its `label`, falling back to its `path`. A cell - * reads the column's dot `path` in the element and draws in the column's - * `format` (omitted: a scalar as `text`); a cell whose value is an object - * or an array, and every cell of an element that is not an object, draws - * as compact JSON text. `[]` draws the header row over an empty-state - * line. A value that is missing is skipped like any other field's, and a - * value that is not an array draws as `json`, as `code-list` does. + * reads the column's dot `path` in the element; a missing value (the + * path resolves to `undefined`) draws an empty cell. A present value + * draws in the column's `format` (omitted: `text`) when it fits that + * format the way a field's value must: `qrcode`, `secret` and `text` take + * a string, `code-list` an array of strings. Any value that does not fit, + * whatever the column's format (an object or an array under the omitted + * `text`, a number under `secret`), draws as compact JSON text, which is + * also how `json` draws in a cell. An element that is not an object has no + * paths to read: its row draws the element itself as compact JSON text in + * the first cell and leaves the other cells empty. `[]` draws the header + * row over an empty-state line. A field value that is missing is skipped + * like any other field's, and one that is not an array draws as `json`, + * as `code-list` does. * `table` is a field format only: it requires `columns` (never guessed * from the element's keys), `columns` is refused beside any other format, * and neither the dialog-level `format` nor a cell takes `table`. From 15c89379669bfeb02b97b9f010bf34b8a1e0d3e9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 00:06:21 +0000 Subject: [PATCH 5/6] test(spec): the strictness site count of action.zod.ts moves 12 -> 13 The table column row adds one strictObject site. Claude-Session: https://claude.ai/code/session_01ADHkmRAxMkAHLvWYP3eojs Co-authored-by: Claude --- packages/spec/scripts/strictness-ledger.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/spec/scripts/strictness-ledger.test.ts b/packages/spec/scripts/strictness-ledger.test.ts index 77c379eb19c..5a06a0f9a33 100644 --- a/packages/spec/scripts/strictness-ledger.test.ts +++ b/packages/spec/scripts/strictness-ledger.test.ts @@ -105,7 +105,9 @@ describe('site counting reads the AST, not the source text', () => { // not counted.) // (9 → 12 at #31840, which ADDED the `preflight`, `preflight.read` and // `preflight.seed` strictObject sites.) - expect(countSites(at('ui/action.zod.ts'))).toBe(12); + // (12 → 13 at #34391, which ADDED the `table` column row's strictObject + // site, `ActionAnswerTableColumnSchema`.) + expect(countSites(at('ui/action.zod.ts'))).toBe(13); }); it('counts a call the source wraps across lines (`z\\n .object({`)', () => { From 635bb5a7ab0681bf71396c424ae17e67c4f5031e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 00:53:21 +0000 Subject: [PATCH 6/6] chore(spec): regenerate the strictness counts on the merged tree Claude-Session: https://claude.ai/code/session_01ADHkmRAxMkAHLvWYP3eojs Co-authored-by: Claude --- .../2026-07-unknown-key-strictness-ledger.counts/ui.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 185f4de2f7a..bd14a2b1cdd 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/` | 222 | 213 | 4 | 0 | 5 | +| `ui/` | 224 | 213 | 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` | 13 | | `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** | **222** | +| **total** | **224** | ## `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 222**, in 4 file(s). +**5 strip of 224**, 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** | **222** | +| **total** | **5** | **224** | | Bucket | Sites | |---|---|