Skip to content

Commit 21e8217

Browse files
committed
fix(lint): run validateChartBindings on view and object publishes
The list-view chart walk now opens the two standalone view shapes the publish door carries (the flattened list overlay and the ViewItem config), and the reference-integrity suite crosses the rule onto view and object writes. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziFPBpGc76tAFHbB8v
1 parent 20457f6 commit 21e8217

2 files changed

Lines changed: 45 additions & 18 deletions

File tree

‎packages/lint/src/reference-integrity-suite.ts‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -422,23 +422,34 @@ export const REFERENCE_INTEGRITY_RULES: readonly ReferenceIntegrityRule[] = [
422422
// every page-door binding as unresolvable. Its page-typed sibling above
423423
// takes the default for the same reason.
424424
{ name: 'validatePageVisualizationBindings', run: validatePageVisualizationBindings },
425-
// [#19542] `runtimeTypes` gains `report` under the ADR-0049 ruling, and ONLY
426-
// `report`. On a report write this member is the subject-reader: it opens
427-
// with `recordsOf(stack.reports)` and resolves that report's own `dataset` /
428-
// `rows` / `columns` / `values` and its chart's axes against `stack.datasets`
429-
// — the one collection this resolution needs and the one the per-write
430-
// snapshot already carries (#7529), so it has no missing-collection
431-
// false-positive channel. ⛔ NOT `dashboard` or `view`: on those writes the
432-
// report/board surfaces the rule walks are the collections the snapshot does
433-
// NOT carry, which is the `dataset` door's own DARK pin one file over.
425+
// [#19542] `runtimeTypes` gains `report` under the ADR-0049 ruling. On a
426+
// report write this member is the subject-reader: it opens with
427+
// `recordsOf(stack.reports)` and resolves that report's own `dataset` /
428+
// `rows` / `columns` / `values` and its chart's axes against
429+
// `stack.datasets` — the one collection this resolution needs and the one
430+
// the per-write snapshot already carries (#7529), so it has no
431+
// missing-collection false-positive channel.
434432
//
435-
// ⚠️ A REFUSAL widening, like #15254's and #19143's: a report republished
436-
// with a dangling dataset binding or a dimension the dataset does not
437-
// declare is now refused (422) rather than stored silently. MEASURED over
438-
// the shipped report corpus at the door's own snapshot shape before
439-
// crossing: 9 reports (showcase 4, todo 5), 8 of them binding a real dataset
440-
// with `rows`/`values` — 0 findings, with a lit synthetic probe refused.
441-
{ name: 'validateChartBindings', runtimeTypes: ['flow', 'report'], run: validateChartBindings },
433+
// [#26847] `view` and `object` join for the same reason. A list-view chart
434+
// (`views[].list` / `listViews`, the flattened overlay, the ViewItem
435+
// `config`, and an object's own `listViews`) binds `dataset` + `dimensions`
436+
// + `values` and resolves against `stack.datasets` ALONE — the collection
437+
// the snapshot carries — so the door refuses an unknown dataset
438+
// (`chart-dataset-unknown`), dimension or measure (`chart-dimension-unknown`
439+
// / `chart-measure-unknown`) the way `os validate` already does. The walk's
440+
// report, page and dashboard surfaces read collections a view or object
441+
// snapshot does not carry, so on those writes they find nothing: they are
442+
// empty there, never dangling. ⛔ Still NOT `dashboard` or `page`: on those
443+
// writes the surfaces the rule walks are the subject, and their sibling
444+
// rules own them.
445+
//
446+
// ⚠️ REFUSAL widenings, like #15254's and #19143's: a report, view or object
447+
// published with a dangling chart binding is now refused (422) rather than
448+
// stored silently. Each was MEASURED over the shipped corpus at the door's
449+
// own snapshot shape before crossing — `report`: 9 reports (showcase 4,
450+
// todo 5), 0 findings; `view` / `object`: MEASURED_VIEW_CORPUS — with a lit
451+
// synthetic probe refused at each door.
452+
{ name: 'validateChartBindings', runtimeTypes: ['flow', 'report', 'view', 'object'], run: validateChartBindings },
442453
// [#26548] The same report, one key on: `dateRange.dimension` resolved
443454
// against the bound dataset's `type: 'date'` dimensions (named, or the ONE
444455
// candidate when omitted). Directly after its sibling because the two read

‎packages/lint/src/validate-chart-bindings.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
* `rows` / `columns` / `values`) is still checked, below.
2828
* 2. **List-view charts** — `ListChartConfigSchema` (`dataset` +
2929
* `dimensions` + `values`), reachable through `views[].list`,
30-
* `views[].listViews.<key>`, and `objects[].listViews.<key>`.
30+
* `views[].listViews.<key>`, `objects[].listViews.<key>`, and the two
31+
* standalone `views[]` shapes `PUT /api/v1/meta/view` carries: the
32+
* flattened list overlay (`viewKind: 'list'`, the chart at the TOP
33+
* level) and the ViewItem record (`viewKind: 'list'`, one level down
34+
* inside `config`). Without those two rungs a view written through the
35+
* publish door is a shape this walk never opens, so crossing the rule
36+
* onto `view` writes would have been a no-op that reads as coverage.
3137
* 3. **Dataset-bound page chart components** — a `PageComponent` whose
3238
* `properties` carry a `dataset` (the `object-chart` component). Same
3339
* binding shape as a list chart, but it arrives through the untyped
@@ -363,7 +369,7 @@ export function validateChartBindings(stack: AnyRec): ChartBindingFinding[] {
363369
if (!stack || typeof stack !== 'object') return findings;
364370

365371
const datasets = indexDatasets(stack);
366-
if (datasets.size === 0 && !stack.reports && !stack.views && !stack.pages) return findings;
372+
if (datasets.size === 0 && !stack.reports && !stack.views && !stack.objects && !stack.pages) return findings;
367373

368374
/**
369375
* Resolve one bound dataset NAME, reporting `chart-dataset-unknown` when it
@@ -624,6 +630,16 @@ export function validateChartBindings(stack: AnyRec): ChartBindingFinding[] {
624630
const view = views[vi];
625631
if (!isRec(view)) continue;
626632
const viewName = strName(view.name) ?? strName(view.objectName) ?? `#${vi}`;
633+
// The two standalone shapes, recognised as `validateListViewFieldRefs`
634+
// recognises them: a flattened overlay carries its chart on the view
635+
// itself, a ViewItem record inside `config`.
636+
if (view.viewKind === 'list') {
637+
if (isRec(view.config)) {
638+
checkListChart(view.config, `view "${viewName}" (ViewItem record) · chart`, `views[${vi}].config`);
639+
} else {
640+
checkListChart(view, `view "${viewName}" (flattened list overlay) · chart`, `views[${vi}]`);
641+
}
642+
}
627643
checkListChart(view.list, `view "${viewName}" · list chart`, `views[${vi}].list`);
628644
if (isRec(view.listViews)) {
629645
for (const [key, lv] of Object.entries(view.listViews)) {

0 commit comments

Comments
 (0)