Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .changeset/19856-joined-report-container-selection-refused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
'@objectstack/spec': minor
---

fix(spec): a `joined` report refuses a top-level `dataset` / `rows` / `columns` / `values`, pointing each onto `blocks[]` (#19856)

Clause-②: no (narrowing)

**BREAKING** — shipped as `minor` under the launch-window convention
(`check-changeset-no-major` refuses `major` until GA; breaking-ness is carried by
this banner, the `(narrowing)` arm above and the ADR-0087 disposition below,
never by the level).

A `joined` report selects nothing itself: each block binds its own `dataset` and
selects its own `rows` / `columns` / `values`, and the renderer's joined branch
reads `blocks` and returns before it reads any top-level selection key.
`ReportSchema` already refused a container-level `order` for exactly that
reason, but the four selection keys beside it parsed green and were then dropped
without a word. Each is now refused at its own path:

```
FROM ReportSchema.safeParse({ name: 'overview', label: 'Overview', type: 'joined',
blocks: [/* … */], dataset: 'tasks', values: ['task_count'] })
-> { success: true } // both keys silently ignored at render

TO -> { success: false, issues: [
{ code: 'custom', path: ['dataset'],
message: 'a `joined` report selects per block — move `dataset` onto `blocks[]`, or delete it; on the container it selects nothing.' },
{ code: 'custom', path: ['values'],
message: 'a `joined` report selects per block — move `values` onto `blocks[]`, or delete it; on the container it selects nothing.' } ] }
```

**Fix.** Move the key onto the `blocks[]` entries that need it, or delete it.
Either way the report renders exactly as before, because the container value was
never read.

**What does not change.** A present `dataset` and a NON-EMPTY list are refused;
an empty `rows` / `columns` / `values` list selects nothing and still parses (the
same threshold as the container `order` refusal, whose message is unchanged). A
joined report's container `runtimeFilter` and `drilldown` — the two container keys
the joined branch does read — parse as before, and every non-joined report is
untouched. An aliased spelling (`measures` → `values`, `dataSet` → `dataset`, …)
is still renamed first, and the renamed key on a joined container then meets this
refusal.

<!-- adr-0087: registered ui-report-joined-container-selection-refused -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import type { SemanticMigration } from '../../types.js';

export const entry: SemanticMigration = {
id: 'ui-report-joined-container-selection-refused',
surface: 'report selection keys on a `joined` container — a top-level `dataset`, or a '
+ 'NON-EMPTY top-level `rows` / `columns` / `values` list, on a report whose `type` is '
+ '`joined` (`ReportSchema`\'s refinement)',
replacement: 'the same key on the `blocks[]` entries that need it — each block binds its own '
+ '`dataset` and selects its own `rows` / `columns` / `values` — or DELETE it. Deleting '
+ 'changes nothing that renders: the container value was never read. The refusal lands at '
+ 'the key\'s own path and says both, the way the container `order` refusal beside it '
+ 'always has, and that `order` refusal is unchanged.',
reason:
'ADR-0049 enforce-or-remove, the enforce arm: the four keys stay declared (they are the '
+ 'selection of every non-joined report), and the one report type that never reads them '
+ 'now refuses them. A `joined` report selects nothing itself, and the refinement already '
+ 'said so for `order` alone — it refused a container `order` with a pointer onto '
+ '`blocks[]` while the four selection keys beside it parsed green. Measured at this '
+ 'repo\'s `.objectui-sha` pin `f8a9d0fb0596f4521076628e2bbfe27e6ce67d52`: '
+ '`DatasetReportRenderer`\'s joined branch (`DatasetReportRenderer.tsx:1462`) reads '
+ '`blocks`, plus the container `runtimeFilter` and `drilldown` resolved above it, and '
+ 'returns before the top-level reads of `columns` / `dataset` / `rows` / `values` begin '
+ '(line 1529 onward) — so each was accepted by the metadata layer and dropped by the '
+ 'renderer without a word. The alias tables made it reachable: `fields` / `measures` / '
+ '`metrics` route to `values`, `groupings` / `groupBy` / `dimensions` to `rows`, and '
+ '`objectName` / `object` / `dataSet` / `source` to `dataset`, on a joined report as on '
+ 'any other. Studio\'s report inspector hides the top-level binding for a joined report '
+ '(`ReportDefaultInspector.tsx:328`) but its type picker patches only `type`, so a '
+ 'report bound first and switched to `joined` second carries the keys invisibly. An '
+ 'empty list is NOT refused: it selects nothing, which is what a joined container '
+ 'selects — the container `order` refusal\'s own threshold. Ships at once, no '
+ 'deprecation window: there is no window in which a key the renderer never reads does '
+ 'anything.',
acceptanceCriteria:
'WHICH DOOR: this is the spec schema\'s refusal, so it lands wherever a report is parsed '
+ 'through `@objectstack/spec` — `defineReport`, `os validate` / `os build`, and the '
+ 'metadata save door (the `report` entry of the metadata type registry) — as one '
+ '`custom` issue per key at `dataset` / `rows` / `columns` / `values`. A stored '
+ '`sys_metadata` report row is not rewritten: it carries the same issue in its read-side '
+ '`_diagnostics` and is refused on its next save. Fix each by moving the key onto the '
+ 'blocks that need it or deleting it, then check the rendered report: it renders exactly '
+ 'as before, because the container value was never read. A joined report that carries '
+ 'only `blocks`, `runtimeFilter`, `drilldown` and the identity / protection keys parses '
+ 'byte-identically to before, and every non-joined report is untouched. Census at the '
+ 'time of the change: zero joined reports carry any of the four at the container — in '
+ 'this repo one example-app report, one docs example and five test fixtures across '
+ '`packages/lint` and `packages/platform-objects`; in objectui every joined-report '
+ 'fixture and docs example at the pin above (13 occurrences); in the cloud repo none '
+ 'exist.',
};
48 changes: 48 additions & 0 deletions packages/spec/src/migrations/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13876,6 +13876,54 @@ const step18: MigrationStep = {
+ 'reports no `component-props-unknown-key` / `component-props-invalid` finding for the '
+ 'rail.',
},
{
id: 'ui-report-joined-container-selection-refused',
surface: 'report selection keys on a `joined` container — a top-level `dataset`, or a '
+ 'NON-EMPTY top-level `rows` / `columns` / `values` list, on a report whose `type` is '
+ '`joined` (`ReportSchema`\'s refinement)',
replacement: 'the same key on the `blocks[]` entries that need it — each block binds its own '
+ '`dataset` and selects its own `rows` / `columns` / `values` — or DELETE it. Deleting '
+ 'changes nothing that renders: the container value was never read. The refusal lands at '
+ 'the key\'s own path and says both, the way the container `order` refusal beside it '
+ 'always has, and that `order` refusal is unchanged.',
reason:
'ADR-0049 enforce-or-remove, the enforce arm: the four keys stay declared (they are the '
+ 'selection of every non-joined report), and the one report type that never reads them '
+ 'now refuses them. A `joined` report selects nothing itself, and the refinement already '
+ 'said so for `order` alone — it refused a container `order` with a pointer onto '
+ '`blocks[]` while the four selection keys beside it parsed green. Measured at this '
+ 'repo\'s `.objectui-sha` pin `f8a9d0fb0596f4521076628e2bbfe27e6ce67d52`: '
+ '`DatasetReportRenderer`\'s joined branch (`DatasetReportRenderer.tsx:1462`) reads '
+ '`blocks`, plus the container `runtimeFilter` and `drilldown` resolved above it, and '
+ 'returns before the top-level reads of `columns` / `dataset` / `rows` / `values` begin '
+ '(line 1529 onward) — so each was accepted by the metadata layer and dropped by the '
+ 'renderer without a word. The alias tables made it reachable: `fields` / `measures` / '
+ '`metrics` route to `values`, `groupings` / `groupBy` / `dimensions` to `rows`, and '
+ '`objectName` / `object` / `dataSet` / `source` to `dataset`, on a joined report as on '
+ 'any other. Studio\'s report inspector hides the top-level binding for a joined report '
+ '(`ReportDefaultInspector.tsx:328`) but its type picker patches only `type`, so a '
+ 'report bound first and switched to `joined` second carries the keys invisibly. An '
+ 'empty list is NOT refused: it selects nothing, which is what a joined container '
+ 'selects — the container `order` refusal\'s own threshold. Ships at once, no '
+ 'deprecation window: there is no window in which a key the renderer never reads does '
+ 'anything.',
acceptanceCriteria:
'WHICH DOOR: this is the spec schema\'s refusal, so it lands wherever a report is parsed '
+ 'through `@objectstack/spec` — `defineReport`, `os validate` / `os build`, and the '
+ 'metadata save door (the `report` entry of the metadata type registry) — as one '
+ '`custom` issue per key at `dataset` / `rows` / `columns` / `values`. A stored '
+ '`sys_metadata` report row is not rewritten: it carries the same issue in its read-side '
+ '`_diagnostics` and is refused on its next save. Fix each by moving the key onto the '
+ 'blocks that need it or deleting it, then check the rendered report: it renders exactly '
+ 'as before, because the container value was never read. A joined report that carries '
+ 'only `blocks`, `runtimeFilter`, `drilldown` and the identity / protection keys parses '
+ 'byte-identically to before, and every non-joined report is untouched. Census at the '
+ 'time of the change: zero joined reports carry any of the four at the container — in '
+ 'this repo one example-app report, one docs example and five test fixtures across '
+ '`packages/lint` and `packages/platform-objects`; in objectui every joined-report '
+ 'fixture and docs example at the pin above (13 occurrences); in the cloud repo none '
+ 'exist.',
},
// The absent-value half of the coupling #6227 declared, recorded beside its
// array half (`view-filter-rule-scalar-operator-array-refused`) rather than
// amended onto it: that entry's own replacement prose told an upgrading author
Expand Down
120 changes: 120 additions & 0 deletions packages/spec/src/ui/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
Report,
JoinedReportBlockSchema,
reportSelectionOrder,
defineReport,
} from './report.zod';
import { strictObjectDeclarations } from '../shared/strict-object';
import { getMetadataTypeSchema } from '../kernel/metadata-type-schemas';

/**
* ADR-0021 single-form: a report binds a `dataset` and selects `rows`
Expand Down Expand Up @@ -99,6 +101,124 @@ describe('Joined reports', () => {
});
});

/**
* A `joined` container selects nothing itself: each block binds its own
* dataset and picks its own dimensions and measures, and the renderer's joined
* branch returns before it reads any top-level selection key. Until this
* refinement, a container `dataset` / `rows` / `columns` / `values` parsed
* green and was then dropped without a word — while `order`, one key over, was
* already refused for exactly that reason.
*
* Every refusal below asserts the envelope a schema door owes: the issue
* `code`, its `path`, and the prescription (the key moves onto `blocks[]`).
*/
describe('Joined reports refuse top-level selection keys', () => {
const BLOCK = { name: 'open_block', type: 'summary', dataset: 'tasks', rows: ['status'], values: ['task_count'] } as const;
const JOINED = { name: 'overview', label: 'Overview', type: 'joined', blocks: [BLOCK] } as const;
const PRESCRIPTION = (key: string) =>
`a \`joined\` report selects per block — move \`${key}\` onto \`blocks[]\`, or delete it; on the container it selects nothing.`;
const ORDER_MESSAGE = 'a `joined` report orders per block — move `order` onto `blocks[]`.';

/** A NON-EMPTY value the key accepts on a plain report, so only the joined arm can refuse it. */
const SELECTION: ReadonlyArray<readonly [string, unknown]> = [
['dataset', 'tasks'],
['rows', ['status']],
['columns', ['priority']],
['values', ['task_count']],
];

it.each(SELECTION)('`%s` on a joined container is refused at its own path, pointing at `blocks[]`', (key, value) => {
const r = ReportSchema.safeParse({ ...JOINED, [key]: value });
expect(r.success, `a joined report carrying \`${key}\` parsed green — the key would be silently dropped`).toBe(false);
expect(r.error!.issues.map((i) => ({ code: i.code, path: i.path, message: i.message }))).toEqual([
{ code: 'custom', path: [key], message: PRESCRIPTION(key) },
]);
});

it('refuses all four at once, one issue per key — and the `order` refusal beside them is unchanged', () => {
const r = ReportSchema.safeParse({
...JOINED,
dataset: 'tasks', rows: ['status'], columns: ['priority'], values: ['task_count'],
order: [{ by: 'task_count' }],
});
expect(r.success).toBe(false);
expect(r.error!.issues.map((i) => ({ code: i.code, path: i.path, message: i.message }))).toEqual([
...SELECTION.map(([key]) => ({ code: 'custom', path: [key], message: PRESCRIPTION(key) })),
{ code: 'custom', path: ['order'], message: ORDER_MESSAGE },
]);
});

it('the authoring factory refuses it too — `defineReport` throws the same prescription', () => {
expect(() => defineReport({ ...JOINED, values: ['task_count'] } as never)).toThrow(PRESCRIPTION('values'));
});

it('the metadata save door refuses it — the registry\'s `report` schema is the same schema', () => {
const saveDoor = getMetadataTypeSchema('report');
expect(saveDoor, 'the `report` metadata type must resolve a schema').toBeDefined();
const r = saveDoor!.safeParse({ ...JOINED, dataset: 'tasks' });
expect(r.success).toBe(false);
expect(r.error!.issues.map((i) => ({ code: i.code, path: i.path, message: i.message }))).toEqual([
{ code: 'custom', path: ['dataset'], message: PRESCRIPTION('dataset') },
]);
});

it('taking the advice parses — each key is accepted on a block', () => {
const r = ReportSchema.safeParse({
...JOINED,
blocks: [{ ...BLOCK, type: 'matrix', dataset: 'tasks', rows: ['status'], columns: ['priority'], values: ['task_count'] }],
});
expect(r.success, JSON.stringify(r.error?.issues ?? [])).toBe(true);
expect(r.data!.blocks![0]).toMatchObject({ dataset: 'tasks', rows: ['status'], columns: ['priority'], values: ['task_count'] });
});

it('an EMPTY list selects nothing, so it is not refused — the same threshold as `order`', () => {
const r = ReportSchema.safeParse({ ...JOINED, rows: [], columns: [], values: [], order: [] });
expect(r.success, JSON.stringify(r.error?.issues ?? [])).toBe(true);
});

it('the container keys a joined report DOES read still parse — `runtimeFilter` and `drilldown`', () => {
const r = ReportSchema.safeParse({ ...JOINED, runtimeFilter: { done: false }, drilldown: false });
expect(r.success, JSON.stringify(r.error?.issues ?? [])).toBe(true);
expect(r.data!.runtimeFilter).toEqual({ done: false });
expect(r.data!.drilldown).toBe(false);
});

it('a non-joined report is untouched — the same four keys are its selection', () => {
const r = ReportSchema.safeParse({
name: 'hours_matrix', label: 'Hours', type: 'matrix',
dataset: 'tasks', rows: ['status'], columns: ['priority'], values: ['task_count'],
});
expect(r.success, JSON.stringify(r.error?.issues ?? [])).toBe(true);
});

/**
* The alias tables route an author ONTO these keys (`measures` → `values`,
* `dataSet` → `dataset`). On a joined report the prescribed key is itself
* refused, with the pointer onto `blocks[]` — the same two-step answer an
* author already gets for `sort` → `order`. The refusal must still be reached
* after the rename; this pins it end to end, both spellings.
*/
it.each([
['measures', 'values', ['task_count']],
['dataSet', 'dataset', 'tasks'],
] as const)('the alias `%s` → `%s` still ends at the joined refusal, and then at `blocks[]`', (alias, target, value) => {
const aliased = ReportSchema.safeParse({ ...JOINED, [alias]: value });
expect(aliased.success).toBe(false);
const unknown = aliased.error!.issues.find((i) => i.code === 'unrecognized_keys');
expect(unknown, `\`${alias}\` must be refused as an unknown key`).toBeDefined();
expect(unknown!.message).toContain(`Did you mean \`${alias}\` → \`${target}\`?`);

const renamed = ReportSchema.safeParse({ ...JOINED, [target]: value });
expect(renamed.success, `taking the rename put \`${target}\` on a joined container and it parsed green`).toBe(false);
expect(renamed.error!.issues.map((i) => ({ code: i.code, path: i.path, message: i.message }))).toEqual([
{ code: 'custom', path: [target], message: PRESCRIPTION(target) },
]);

const moved = ReportSchema.safeParse({ ...JOINED, blocks: [{ ...BLOCK, [target]: value }] });
expect(moved.success, JSON.stringify(moved.error?.issues ?? [])).toBe(true);
});
});

/**
* #3916 — reports can declare an ordering. Before this the report schema had no
* sort field at all: `DatasetSelection.order` existed but was unreachable for
Expand Down
Loading
Loading