From c0d2fcf2ee0a0ec86e06aa0aedaaecbc68560ca8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 00:26:20 +0000 Subject: [PATCH 1/8] feat(lint): publish-time checks for views, dashboards and the app shell that save and do not work Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- packages/lint/src/authoring-rules.ts | 37 ++- packages/lint/src/index.ts | 15 + packages/lint/src/rule-explanations.ts | 100 +++++++ packages/lint/src/validate-app-shell-reach.ts | 266 ++++++++++++++++++ .../lint/src/validate-list-view-field-refs.ts | 121 ++++++++ packages/lint/src/validate-widget-bindings.ts | 43 ++- 6 files changed, 580 insertions(+), 2 deletions(-) create mode 100644 packages/lint/src/validate-app-shell-reach.ts diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts index d91276cdd06..eafb8f7da07 100644 --- a/packages/lint/src/authoring-rules.ts +++ b/packages/lint/src/authoring-rules.ts @@ -104,6 +104,7 @@ import { validateManagedApiMethods } from './validate-managed-api-methods.js'; import { validateTransferCascades } from './validate-transfer-cascades.js'; import { validateViewContainers } from './validate-view-containers.js'; import { validateWidgetBindings } from './validate-widget-bindings.js'; +import { validateAppNavigationPresent, validateObjectShellReach } from './validate-app-shell-reach.js'; import { validateDatasetMeasureAggregates } from './validate-dataset-measure-aggregates.js'; import { validateDatasetMemberVocabulary } from './validate-dataset-member-vocabulary.js'; import { validateDashboardActionRefs } from './validate-dashboard-action-refs.js'; @@ -1084,7 +1085,11 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ source: 'packages/lint/src/validate-widget-bindings.ts', surfaces: CLI_AND_RUNTIME, runtimeTypes: ['dashboard'], - run: (stack) => validateWidgetBindings(stack), + // [#35143] `dashboard-without-widgets` is an error on the CLI and a warning + // at the runtime door, where Studio's own create paths save a dashboard + // with `widgets: []` before its first widget; `runtimeWriteType` is set by + // the runtime gate alone. + run: (stack, ctx) => validateWidgetBindings(stack, { atPublishDoor: ctx.runtimeWriteType !== undefined }), }, // #16354 — the AUTHORING-TIME leg of the aggregate × field-type contract // (director ruling, decision batch #59, 2026-09-06: "both legs, table in @@ -3437,6 +3442,36 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ // `base_namespace_too_long`), so the ensure door will refuse to create its // `.custom` pair and its installers can never customize it. Advisory: the // package builds, installs and runs, and only its customization is refused. + // [#35143] An app with no navigation entry (`app-navigation-empty`): the + // console's app root renders the "no access" empty state to every member. + // ADVISORY: Studio may save a new app before its first entry, and another + // package may contribute the entries (ADR-0029 D7). The written app is the + // whole question, so it runs on the runtime `app` door as on the CLI. + { + name: 'validateAppNavigationPresent', + tier: 'advisory', + input: 'parsed', + commands: ALL, + source: 'packages/lint/src/validate-app-shell-reach.ts', + surfaces: CLI_AND_RUNTIME, + runtimeTypes: ['app'], + run: (stack) => validateAppNavigationPresent(stack), + }, + // [#35143] An object no app's navigation opens + // (`object-unreachable-from-navigation`), and an object navigation opens that + // declares no list view (`object-without-view`). ADVISORY: both work, and + // show the user less than was built. CLI only: the verdict reads every app, + // view and object of the stack, which no per-write snapshot carries. + { + name: 'validateObjectShellReach', + tier: 'advisory', + input: 'parsed', + commands: ALL, + source: 'packages/lint/src/validate-app-shell-reach.ts', + surfaces: CLI_ONLY, + surfaceReason: RUNTIME_NEEDS_FULL_SNAPSHOT, + run: (stack) => validateObjectShellReach(stack), + }, // `normalized` because it reads one string off each delivered manifest and // needs no parsed stack, so `os lint` judges it too. { diff --git a/packages/lint/src/index.ts b/packages/lint/src/index.ts index 988e574abb5..4a4a9b3e404 100644 --- a/packages/lint/src/index.ts +++ b/packages/lint/src/index.ts @@ -36,6 +36,9 @@ export { WIDGET_LEGACY_ANALYTICS_UNRENDERABLE, DASHBOARD_FILTER_FIELD_UNKNOWN, DASHBOARD_FILTER_FIELD_UNPROVISIONED, + // [#35143] A dashboard with no widgets: an error on the CLI, a warning at + // the runtime door, where Studio creates a dashboard empty. + DASHBOARD_WITHOUT_WIDGETS, // [#14275] The `include` clause on a DASHBOARD-level filter's effective // field, now that it is resolved on the object graph rather than skipped // whenever it was dotted. @@ -709,6 +712,10 @@ export { LIST_VIEW_CHART_DATASET_FOREIGN_OBJECT, LIST_VIEW_KANBAN_LANE_UNKNOWN, LIST_VIEW_KANBAN_LANE_REPEATED, + // [#35143] A board grouped by a field with no fixed lanes (advisory), and a + // filter keyed on a field computed on read (refused). + LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL, + LIST_VIEW_FILTER_FIELD_VIRTUAL, LIST_VIEW_OBJECT_OUTSIDE_CLOSURE, LIST_VIEW_OBJECT_UNKNOWN, LIST_VIEW_KEY_RETIRED, @@ -1149,6 +1156,14 @@ export { // the registry and are not exported. export { ACTION_BODY_WRITE_CAPABILITY_UNDECLARED } from './validate-action-body-capabilities.js'; export { SEED_RECORD_UNKNOWN_FIELD } from './validate-seed-record-keys.js'; +// [#35143] The Views, dashboards and app shell family's app-shell ids, all +// advisory, exported for `os explain` as the two above; the rules run through +// the registry and are not exported. +export { + APP_NAVIGATION_EMPTY, + OBJECT_UNREACHABLE_FROM_NAVIGATION, + OBJECT_WITHOUT_VIEW, +} from './validate-app-shell-reach.js'; export type { ActionBodyCompileFinding, HostCompileFailure, diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index d877ce13c05..bc405d7cdd9 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -1542,6 +1542,100 @@ const SEED_RECORD_UNKNOWN_FIELD_EXPLANATION: RuleExplanation = { ], }; +const LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL_EXPLANATION: RuleExplanation = { + rule: 'list-view-kanban-group-field-uncategorical', + covers: 'which fields a kanban board can draw its lanes from', + paragraphs: [ + 'A kanban board draws its lanes from the options of the field named by `groupByField`. A field with no ' + + 'options gets lanes from the values on the cards the board has loaded instead: a lookup gets one lane ' + + 'per record it names, a boolean gets two. For a text, number or date field that means one lane per ' + + 'distinct value, often one per card, no lane for a value no loaded card holds (so no card can be ' + + 'dragged there), and no lanes at all while the list is empty. A multi-valued field (`multiselect`, ' + + '`checkboxes`, `tags`, or a `multiple` select or reference) puts a card holding several values in one ' + + 'lane named by all of them together.', + 'A warning: every card still renders and a drag still writes the lane\'s value, so the board groups, but ' + + 'not into lanes anyone chose. Judged on a list view whose `type` is `kanban`, against the group field\'s ' + + 'declaration. Not judged: a dotted `groupByField`, one that names no field (`list-view-field-unknown`), ' + + 'and a field whose type is not readable.', + 'To fix it, group the board by a single-valued `select` field (one lane per option), a boolean or a ' + + 'lookup; or show the field as a grid column or grouping instead of board lanes.', + ], +}; + +const LIST_VIEW_FILTER_FIELD_VIRTUAL_EXPLANATION: RuleExplanation = { + rule: 'list-view-filter-field-virtual', + covers: 'why a list view cannot filter on a formula field', + paragraphs: [ + 'A `formula` field is computed when a record is read and has no stored column. The engine therefore ' + + 'refuses every query whose filter names one (`400 INVALID_FIELD`), rather than answering with no ' + + 'records in both directions. A list view whose own `filter`, or a `userFilters.tabs[]` preset, keys on ' + + 'a formula sends that query on every open: the view shows the error and no records.', + 'An error, so the publish is refused and `os validate` and `os build` fail. Judged at an undotted filter ' + + 'key that resolves on the bound object; a dotted key whose head is a formula is `list-view-field-dotted`. ' + + 'The filter bar\'s field list (`userFilters.fields`) is not judged: it offers a field, it does not filter.', + 'To fix it, filter on the stored fields the formula reads, or keep the value in a stored field written ' + + 'when its sources change and filter on that; or remove the condition.', + ], +}; + +const DASHBOARD_WITHOUT_WIDGETS_EXPLANATION: RuleExplanation = { + rule: 'dashboard-without-widgets', + covers: 'why a dashboard needs a widget', + paragraphs: [ + 'A dashboard with `widgets: []` parses and publishes, and opens on its header over an empty canvas: the ' + + 'renderer draws no empty state for it, so a user reaching it from navigation sees nothing and is told ' + + 'nothing.', + 'An error on `os validate`, `os lint` and `os build`, where a shipped package has nothing left to add. A ' + + 'warning at the runtime publish door, because Studio creates a new dashboard with `widgets: []` and ' + + 'fills it afterwards, and the door must not refuse the platform\'s own first step.', + 'To fix it, add a widget bound to a dataset, or remove the dashboard and any navigation entry that ' + + 'opens it.', + ], +}; + +const APP_NAVIGATION_EMPTY_EXPLANATION: RuleExplanation = { + rule: 'app-navigation-empty', + covers: 'why an app needs a navigation entry', + paragraphs: [ + 'The console opens an app on its first navigation entry. An app with no entry, in `navigation` or in any ' + + '`areas[].navigation` (a `separator`, or a `group` with nothing under it, counts as nothing), opens on ' + + 'the "no access" empty state, for every member and for its author.', + 'A warning: Studio may save a new app before its first entry, and another package may contribute the ' + + 'entries (`navigationContributions`). Contributions this stack makes into the app are counted. Runs on ' + + 'the runtime `app` door as on `os validate`, `os lint` and `os build`.', + 'To fix it, add an entry that opens an object, a page, a dashboard or a report, or remove the app.', + ], +}; + +const OBJECT_UNREACHABLE_FROM_NAVIGATION_EXPLANATION: RuleExplanation = { + rule: 'object-unreachable-from-navigation', + covers: 'when an object is reachable from the app shell', + paragraphs: [ + 'An object is reachable when some app\'s navigation, or navigation the stack contributes into another ' + + 'package\'s app, names it in a `type: \'object\'` entry. An object nothing names is stored and served, ' + + 'but no user can open its list from the shell.', + 'A warning, on `os validate`, `os lint` and `os build` only: the verdict reads every app and object of ' + + 'the stack, which the runtime door\'s per-write snapshot does not carry. Not judged: a stack with no ' + + 'app and no contributed navigation, an object with a `master_detail` field (it shows as a related list ' + + 'on its parent), and an object whose `enable.apiEnabled` is `false`.', + 'To fix it, add a `type: \'object\'` entry for it to an app\'s navigation, or make it the child of the ' + + 'object it belongs to with a `master_detail` field.', + ], +}; + +const OBJECT_WITHOUT_VIEW_EXPLANATION: RuleExplanation = { + rule: 'object-without-view', + covers: 'what an object opened from navigation shows without a list view', + paragraphs: [ + 'An object a navigation entry opens, with no `list`, no `listViews` entry and no `views` item bound to it, ' + + 'opens on an "All records" tab the console builds itself: the name field followed by `highlightFields`, ' + + 'or by the first five fields in declared order, with no filter, sort or grouping and no other tab.', + 'A warning, on `os validate`, `os lint` and `os build` only, for the reason `object-unreachable-from-' + + 'navigation` gives. Judged only for objects navigation opens, the one place that list is shown.', + 'To fix it, declare the list users should see: a `list` on the object, or a `views` entry bound to it.', + ], +}; + /** Shared by the hook and job compile rules: the two bodies run in one wrapper. */ const CTX_BODY_COMPILE: readonly string[] = [ 'The rule compiles the body inside the same expression the runtime builds, from the same function, ' + @@ -7100,6 +7194,12 @@ export const RULE_EXPLANATIONS: Readonly> = Obje [ACTION_BODY_DOES_NOT_COMPILE_EXPLANATION.rule]: ACTION_BODY_DOES_NOT_COMPILE_EXPLANATION, [ACTION_BODY_WRITE_CAPABILITY_UNDECLARED_EXPLANATION.rule]: ACTION_BODY_WRITE_CAPABILITY_UNDECLARED_EXPLANATION, [SEED_RECORD_UNKNOWN_FIELD_EXPLANATION.rule]: SEED_RECORD_UNKNOWN_FIELD_EXPLANATION, + [LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL_EXPLANATION.rule]: LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL_EXPLANATION, + [LIST_VIEW_FILTER_FIELD_VIRTUAL_EXPLANATION.rule]: LIST_VIEW_FILTER_FIELD_VIRTUAL_EXPLANATION, + [DASHBOARD_WITHOUT_WIDGETS_EXPLANATION.rule]: DASHBOARD_WITHOUT_WIDGETS_EXPLANATION, + [APP_NAVIGATION_EMPTY_EXPLANATION.rule]: APP_NAVIGATION_EMPTY_EXPLANATION, + [OBJECT_UNREACHABLE_FROM_NAVIGATION_EXPLANATION.rule]: OBJECT_UNREACHABLE_FROM_NAVIGATION_EXPLANATION, + [OBJECT_WITHOUT_VIEW_EXPLANATION.rule]: OBJECT_WITHOUT_VIEW_EXPLANATION, [HOOK_BODY_DOES_NOT_COMPILE_EXPLANATION.rule]: HOOK_BODY_DOES_NOT_COMPILE_EXPLANATION, [JOB_BODY_DOES_NOT_COMPILE_EXPLANATION.rule]: JOB_BODY_DOES_NOT_COMPILE_EXPLANATION, [ACTION_BODY_WRITE_UNPROVISIONED_ANCHOR_EXPLANATION.rule]: ACTION_BODY_WRITE_UNPROVISIONED_ANCHOR_EXPLANATION, diff --git a/packages/lint/src/validate-app-shell-reach.ts b/packages/lint/src/validate-app-shell-reach.ts new file mode 100644 index 00000000000..6243e2360f8 --- /dev/null +++ b/packages/lint/src/validate-app-shell-reach.ts @@ -0,0 +1,266 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The app shell an author ships, judged for the three ways it publishes and + * then shows the user less than was built (#35143, Views, dashboards and app + * shell family). All three are advisory: each shape is a legitimate step in + * building an app, and none of them breaks a request. + * + * ## `app-navigation-empty` — an app with no navigation entry + * + * The console's app root asks whether the app serves any entry at all + * (`appServesNoNavigation` in objectui, over the app's `navigation` and every + * `areas[].navigation`, with a `separator` and a `group` with no entry under it + * counting as nothing), and on a no it renders the "no access" empty state to + * every member, the author included: the app opens on nothing. Navigation + * another package contributes into the app (`navigationContributions`, + * ADR-0029 D7) does count, and this stack's own contributions are read; a + * contribution from a package this stack cannot see is why the rule is a + * warning, as is Studio, which may save a new app before its first entry. + * Runs on the runtime `app` door: the written app is the whole question. + * + * ## `object-unreachable-from-navigation` — an object no app opens + * + * An object the stack declares and no navigation entry of any app (nor any + * navigation the stack contributes into another package's app) names in a + * `type: 'object'` entry. Its records exist and its API answers, but no user + * can open its list from the shell. Not judged: + * + * - a stack that declares no app and contributes no navigation (a package of + * objects other packages present); + * - an object with a `master_detail` field: it is shown as a related list on + * its parent's record page, which is where such a child belongs; + * - an object whose `enable.apiEnabled` is `false`: its list cannot be served, + * which `nav-object-unservable` already says of any entry that opens it. + * + * ## `object-without-view` — an object opened from navigation with no list view + * + * An object a navigation entry opens that declares no list view: no `list`, no + * `listViews` entry, and no `views[]` item bound to it. The console then + * builds an "All records" tab of its own (`buildViewTabs`' fallback in + * objectui): the name field followed by `highlightFields`, or by the first five + * fields in declared order, with no filter, sort or grouping and no second tab. + * It works; it is the list nobody designed. Judged only where navigation opens + * the object, which is the one place that list is shown. + * + * The two object findings need every app, view and object of the stack, a + * collection the runtime gate's per-write snapshot does not carry, so they run + * on `os validate` / `lint` / `build` only. + */ + +import { packagesOf, recordsOf } from './object-graph.js'; + +type AnyRec = Record; + +export const APP_NAVIGATION_EMPTY = 'app-navigation-empty'; +export const OBJECT_UNREACHABLE_FROM_NAVIGATION = 'object-unreachable-from-navigation'; +export const OBJECT_WITHOUT_VIEW = 'object-without-view'; + +export interface AppShellReachFinding { + severity: 'warning'; + rule: string; + where: string; + path: string; + message: string; + hint: string; +} + +const isRec = (v: unknown): v is AnyRec => !!v && typeof v === 'object' && !Array.isArray(v); +const strName = (v: unknown): string | undefined => (typeof v === 'string' && v.length > 0 ? v : undefined); + +/** + * Whether a navigation tree holds an entry the shell draws: anything but a + * `separator`, and a `group` only through an entry under it — the structural + * half of objectui's `hasVisibleNavigationItems`, with no gate asked. + */ +function hasEntry(items: unknown): boolean { + if (!Array.isArray(items)) return false; + return items.some((item) => { + if (!isRec(item)) return false; + if (item.type === 'separator') return false; + if (item.type === 'group') return hasEntry(item.children); + return true; + }); +} + +/** Every `objectName` a `type: 'object'` entry names in a navigation tree, at any depth. */ +function collectNavObjects(items: unknown, into: Set): void { + if (!Array.isArray(items)) return; + for (const item of items) { + if (!isRec(item)) continue; + const objectName = item.type === 'object' ? strName(item.objectName) : undefined; + if (objectName) into.add(objectName); + if (item.type !== 'separator') collectNavObjects(item.children, into); + } +} + +/** One collection holder: the stack itself, then each `packages[].manifest` body. */ +interface Holder { + body: AnyRec; + /** Path prefix of the holder, `''` for the stack itself. */ + prefix: string; +} + +function holdersOf(stack: AnyRec): Holder[] { + const holders: Holder[] = [{ body: stack, prefix: '' }]; + packagesOf(stack).forEach((entry, i) => { + if (isRec(entry.manifest)) holders.push({ body: entry.manifest, prefix: `packages[${i}].manifest.` }); + }); + return holders; +} + +/** The navigation contributions a holder makes: its own key, or its manifest's. */ +function contributionsOf(body: AnyRec): AnyRec[] { + const own = recordsOf(body.navigationContributions); + const viaManifest = isRec(body.manifest) ? recordsOf(body.manifest.navigationContributions) : []; + return [...own, ...viaManifest]; +} + +/** The apps a holder declares, with each one's path. */ +function appsOf(holder: Holder): Array<{ app: AnyRec; path: string; name: string }> { + const apps = holder.body.apps; + if (Array.isArray(apps)) { + return apps.flatMap((app, i) => + isRec(app) ? [{ app, path: `${holder.prefix}apps[${i}]`, name: strName(app.name) ?? `#${i}` }] : [], + ); + } + if (isRec(apps)) { + return Object.entries(apps).flatMap(([name, app]) => + isRec(app) ? [{ app, path: `${holder.prefix}apps.${name}`, name: strName(app.name) ?? name }] : [], + ); + } + return []; +} + +/** Every app `name` some navigation contribution of the stack targets. */ +function contributedAppNames(holders: readonly Holder[]): Set { + const names = new Set(); + for (const holder of holders) { + for (const contribution of contributionsOf(holder.body)) { + const app = strName(contribution.app); + if (app && hasEntry(contribution.items)) names.add(app); + } + } + return names; +} + +/** + * `app-navigation-empty`: every app with no entry in `navigation` nor in any + * `areas[].navigation`, and no contribution of this stack into it. + */ +export function validateAppNavigationPresent(stack: AnyRec): AppShellReachFinding[] { + const findings: AppShellReachFinding[] = []; + if (!isRec(stack)) return findings; + const holders = holdersOf(stack); + const contributed = contributedAppNames(holders); + for (const holder of holders) { + for (const { app, path, name } of appsOf(holder)) { + if (hasEntry(app.navigation)) continue; + if (recordsOf(app.areas).some((area) => hasEntry(area.navigation))) continue; + if (contributed.has(name)) continue; + findings.push({ + severity: 'warning', + rule: APP_NAVIGATION_EMPTY, + where: `app "${name}"`, + path: `${path}.navigation`, + message: + `app "${name}" has no navigation entry (none in \`navigation\` or in any \`areas[].navigation\`), so ` + + 'it opens on the "no access" empty state for every member, its author included', + hint: + "Add an entry that opens something, e.g. `navigation: [{ id: 'nav_home', type: 'object', label: '…', " + + "objectName: '' }]`, or remove the app", + }); + } + } + return findings; +} + +/** Whether a list-view-bearing view record binds `object`. */ +function viewBinds(view: AnyRec, object: string): boolean { + const bound = (v: unknown): string | undefined => + isRec(v) && isRec(v.data) ? strName(v.data.object) : undefined; + if (strName(view.objectName) === object || strName(view.object) === object) return true; + if (bound(view) === object || bound(view.list) === object || bound(view.config) === object) return true; + return isRec(view.listViews) && Object.values(view.listViews).some((lv) => bound(lv) === object); +} + +/** Whether an object declares a list view of its own. */ +function declaresOwnView(obj: AnyRec): boolean { + if (isRec(obj.list)) return true; + return isRec(obj.listViews) && Object.values(obj.listViews).some(isRec); +} + +function hasMasterDetailField(obj: AnyRec): boolean { + return recordsOf(obj.fields).some((f) => f.type === 'master_detail'); +} + +/** + * `object-unreachable-from-navigation` and `object-without-view` over every + * object the stack (and each package of an assembled artifact) declares. + */ +export function validateObjectShellReach(stack: AnyRec): AppShellReachFinding[] { + const findings: AppShellReachFinding[] = []; + if (!isRec(stack)) return findings; + const holders = holdersOf(stack); + + const reached = new Set(); + let navigates = false; + for (const holder of holders) { + for (const { app } of appsOf(holder)) { + navigates = true; + collectNavObjects(app.navigation, reached); + for (const area of recordsOf(app.areas)) collectNavObjects(area.navigation, reached); + } + for (const contribution of contributionsOf(holder.body)) { + navigates = true; + collectNavObjects(contribution.items, reached); + } + } + if (!navigates) return findings; + + const views = holders.flatMap((holder) => recordsOf(holder.body.views)); + + for (const holder of holders) { + const objects = holder.body.objects; + if (!Array.isArray(objects)) continue; + objects.forEach((obj, i) => { + if (!isRec(obj)) return; + const name = strName(obj.name); + if (!name) return; + const path = `${holder.prefix}objects[${i}]`; + if (!reached.has(name)) { + if (hasMasterDetailField(obj)) return; + if (isRec(obj.enable) && obj.enable.apiEnabled === false) return; + findings.push({ + severity: 'warning', + rule: OBJECT_UNREACHABLE_FROM_NAVIGATION, + where: `object "${name}"`, + path, + message: + `no app's navigation opens object "${name}" (no \`type: 'object'\` entry names it), so its records ` + + 'are stored and served but no user can reach its list from the app shell', + hint: + `Add \`{ id: 'nav_${name}', type: 'object', label: '…', objectName: '${name}' }\` to an app's ` + + '`navigation`, or make it a child of the object it belongs to (a `master_detail` field) so it shows ' + + "as a related list on the parent's record page", + }); + return; + } + if (declaresOwnView(obj) || views.some((view) => viewBinds(view, name))) return; + findings.push({ + severity: 'warning', + rule: OBJECT_WITHOUT_VIEW, + where: `object "${name}"`, + path, + message: + `object "${name}" is opened from navigation but declares no list view, so the console builds an ` + + '"All records" tab of its own: the name field and `highlightFields` (or the first five fields), ' + + 'with no filter, sort or grouping and no other tab', + hint: + `Declare the list users should see: \`list: { type: 'grid', columns: [...] }\` on "${name}", or a ` + + `\`views\` entry bound to it (\`defineView({ object: '${name}', list: { ... } })\`)`, + }); + }); + } + return findings; +} diff --git a/packages/lint/src/validate-list-view-field-refs.ts b/packages/lint/src/validate-list-view-field-refs.ts index 331848f9dc9..bb533664012 100644 --- a/packages/lint/src/validate-list-view-field-refs.ts +++ b/packages/lint/src/validate-list-view-field-refs.ts @@ -448,6 +448,40 @@ * `groupByField` that resolves to nothing, which is `list-view-field-unknown` * at that key. * + * ## [#35143] A board grouped by a field with no lanes of its own + * + * {@link LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL}, `warning`. The board + * (`ObjectKanban.tsx` in objectui) draws its lanes from the group field's + * declared `options`, else — a lookup, a boolean, anything else — from the + * distinct values on the cards it has loaded (`lanesFromRecords`). For a + * `select` / `radio`, a boolean or a single-valued reference that is a small, + * fixed set. For any other field it is not: a text, number or date field + * draws one lane per distinct value (often one per card), no lane exists for + * a value no loaded card holds, so a card cannot be dragged to it, and an + * empty board draws no lanes at all. A multi-valued field (`multiselect`, + * `checkboxes`, `tags`, a `multiple` select or reference) puts a card holding + * several values in one lane named by all of them together. + * + * Advisory, not refused: every card still renders and a drag still writes + * the lane's value, so the board works as a grouping — it is the wrong one. + * Judged only on a list view whose `type` is `kanban`, against the group + * field's resolved declaration; a dotted `groupByField`, an unresolved one + * (`list-view-field-unknown`) and a field whose type is not readable are not + * judged. + * + * ## [#35143] A filter on a field computed on read + * + * {@link LIST_VIEW_FILTER_FIELD_VIRTUAL}, `error`. A `formula` field has no + * stored column, so the engine refuses every query whose `where` names one + * (`assertFilterIsMaterializable` in `@objectstack/objectql`, `400 + * INVALID_FIELD`): a list view whose own `filter`, or a `userFilters.tabs[]` + * preset, keys on a formula opens on that error, every time, with no records. + * Virtuality is the spec's storage predicate (`isVirtualSearchField`), the one + * the engine's door asks. Judged at an undotted key whose head resolves; a + * dotted key whose head is a formula is already {@link LIST_VIEW_FIELD_DOTTED}. + * The filter-bar FIELD list (`userFilters.fields`) is not judged here: it + * offers a field to filter on, it does not filter. + * * ## Skips — the same three every field-existence rule in this package takes * * Resolution is {@link resolveFieldPath}'s and its `unknowable` verdicts are @@ -471,8 +505,11 @@ import { BOOLEAN_VALUE_TYPES, FieldType, + REFERENCE_VALUE_TYPES, classifyDottedFilterHead, isAggregateCompatibleWithFieldType, + isMultiValueField, + isVirtualSearchField, virtualFieldAggregateRemedy, } from '@objectstack/spec/data'; import { @@ -566,6 +603,33 @@ export const LIST_VIEW_KANBAN_LANE_UNKNOWN = 'list-view-kanban-lane-unknown'; */ export const LIST_VIEW_KANBAN_LANE_REPEATED = 'list-view-kanban-lane-repeated'; +/** + * [#35143] A `kanban` board grouped by a field that has no fixed set of lanes. + * Advisory. See the section "A board grouped by a field with no lanes of its + * own" on this module. + */ +export const LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL = 'list-view-kanban-group-field-uncategorical'; + +/** + * [#35143] A list view filter — its own `filter` or a `userFilters.tabs[]` + * preset — keyed on a field computed on read (`formula`), which the engine + * refuses to filter by. See the section "A filter on a field computed on read" + * on this module. + */ +export const LIST_VIEW_FILTER_FIELD_VIRTUAL = 'list-view-filter-field-virtual'; + +/** + * [#35143] The field types a board can draw a fixed set of lanes from, when + * the field holds one value: the options of a `select` / `radio`, the two + * values of a boolean, and the records a single-valued reference names. + */ +const KANBAN_CATEGORICAL_TYPES: ReadonlySet = new Set([ + 'select', + 'radio', + ...BOOLEAN_VALUE_TYPES, + ...REFERENCE_VALUE_TYPES, +]); + /** * A list view that still carries a key `@objectstack/spec` retired — reported * BY NAME, with the tombstone's own prescription, never as a field reference. @@ -1393,6 +1457,37 @@ export function validateListViewFieldRefs( }); }; + /** + * [#35143] A `kanban` board grouped by a field with no fixed set of lanes — + * see the section "A board grouped by a field with no lanes of its own" on + * this module. Once per list view, at `kanban.groupByField`. + */ + const checkKanbanGroupField = (listView: AnyRec, object: string, where: string, path: string): void => { + if (listView.type !== 'kanban' || !isRec(listView.kanban)) return; + const groupBy = strName(listView.kanban.groupByField); + if (!groupBy || groupBy.includes('.')) return; + const verdict = resolveFieldPath(graph, object, groupBy); + if (!verdict || verdict.kind !== 'ok' || !verdict.meta?.type) return; + const { type, multiple } = verdict.meta; + const multi = isMultiValueField({ type, multiple } as never); + if (!multi && KANBAN_CATEGORICAL_TYPES.has(type)) return; + findings.push({ + severity: 'warning', + rule: LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL, + where: `${where} › kanban`, + path: `${path}.kanban.groupByField`, + message: multi + ? `the board is grouped by "${object}.${groupBy}", a multi-valued \`${type}\` field: a card holding ` + + 'several values falls into one lane named by all of them together, not into a lane per value' + : `the board is grouped by "${object}.${groupBy}", a \`${type}\` field with no fixed set of values: the ` + + 'board draws one lane per distinct value among the cards it has loaded, no lane for a value no card ' + + 'holds (so no card can be dragged there), and no lanes at all while the list is empty', + hint: + `Group the board by a single-valued \`select\` field of "${object}" (one lane per option), a boolean or a ` + + `lookup; or show "${groupBy}" as a grid column or grouping instead of board lanes`, + }); + }; + /** * Judge ONE written reference at one position. * @@ -1640,6 +1735,7 @@ export function validateListViewFieldRefs( } checkKanbanLanes(listView, bound, where, path); + checkKanbanGroupField(listView, bound, where, path); // [#36370, #36520] The lane foot statistic: the field it names, then the // `sum` / `avg` / `min` / `max` over that field's declaration. @@ -1670,10 +1766,35 @@ export function validateListViewFieldRefs( // on every list-view shape, and this rule judges the PARSED stack // (`input: 'parsed'` in the authoring-rule registry), where the key can // never arrive — the parse refuses it with its prescription first. + // [#35143] A filter key naming a field computed on read — see the section + // "A filter on a field computed on read" on this module. An undotted key + // only: a dotted one is the dotted verdict's, judged by `check` above. + const checkFilterVirtual = (raw: unknown, object: string, filterWhere: string, at: string): void => { + const written = strName(raw); + if (!written || written.includes('.')) return; + const verdict = resolveFieldPath(graph, object, written); + if (!verdict || verdict.kind !== 'ok' || !isVirtualSearchField(verdict.meta as never)) return; + const type = verdict.meta?.type ?? 'formula'; + findings.push({ + severity: 'error', + rule: LIST_VIEW_FILTER_FIELD_VIRTUAL, + where: filterWhere, + path: at, + message: + `filter key "${written}" is a \`${type}\` field of "${object}": its value is computed on read and no store ` + + 'keeps a column for it, so the engine refuses the list\'s query (400 INVALID_FIELD) and the view opens on ' + + 'that error with no records', + hint: + `Filter on the stored fields of "${object}" that the formula reads, or keep the value in a stored field ` + + `written when its sources change and filter on that; or remove the "${written}" condition`, + }); + }; + const checkFilter = (filter: unknown, filterWhere: string, filterPath: string): void => { if (filter === undefined || filter === null) return; walkFilterFieldKeys(filter, filterPath, ({ field, path: at }) => { check(field, bound, 'error', filterWhere, at, 'filter key', 'filter'); + checkFilterVirtual(field, bound, filterWhere, at); }); }; diff --git a/packages/lint/src/validate-widget-bindings.ts b/packages/lint/src/validate-widget-bindings.ts index 1254a2305c2..60866cd1566 100644 --- a/packages/lint/src/validate-widget-bindings.ts +++ b/packages/lint/src/validate-widget-bindings.ts @@ -450,6 +450,17 @@ export const TABLE_COUNT_ONLY = 'table-count-only'; export const MEASURE_AGGREGATE_INCOHERENT = 'measure-aggregate-incoherent'; export const WIDGET_LEGACY_ANALYTICS_SHAPE = 'widget-legacy-analytics-shape'; export const WIDGET_LEGACY_ANALYTICS_UNRENDERABLE = 'widget-legacy-analytics-unrenderable'; +/** + * [#35143] A dashboard that declares no widget: it publishes and opens on its + * header over an empty canvas (`DashboardRenderer.tsx` in objectui draws no + * empty state for it). An `error` on `os validate` / `lint` / `build`, where a + * shipped package has nothing left to add; a `warning` at the runtime publish + * door, because Studio's own create paths save a new dashboard with + * `widgets: []` and fill it afterwards (`newItemBody` in `designModeMenuCreate.ts`, + * the `dashboard` resource's `createDefaults` in `anchors.ts`), and refusing + * that save would refuse the platform's own first step. + */ +export const DASHBOARD_WITHOUT_WIDGETS = 'dashboard-without-widgets'; export const DASHBOARD_FILTER_FIELD_UNKNOWN = 'dashboard-filter-field-unknown'; export const DASHBOARD_FILTER_FIELD_UNPROVISIONED = 'dashboard-filter-field-unprovisioned'; /** @@ -494,6 +505,16 @@ const LEGACY_ANALYTICS_KEYS = [ export type WidgetBindingSeverity = 'error' | 'warning'; +/** How {@link validateWidgetBindings} is being called. */ +export interface WidgetBindingOptions { + /** + * [#35143] Set by the runtime publish gate's entry: the stack is the + * snapshot of one write at the save/publish door, where + * {@link DASHBOARD_WITHOUT_WIDGETS} is advisory. + */ + atPublishDoor?: boolean; +} + export interface WidgetBindingFinding { /** `error` = unresolvable binding (broken page); `warning` = advisory. */ severity: WidgetBindingSeverity; @@ -1100,7 +1121,10 @@ function measureColumn(measure: AnyRec): string | undefined { * should fail validate/build; `warning` findings are advisory and must * never fail the build on their own. */ -export function validateWidgetBindings(stack: AnyRec): WidgetBindingFinding[] { +export function validateWidgetBindings( + stack: AnyRec, + options?: WidgetBindingOptions, +): WidgetBindingFinding[] { const findings: WidgetBindingFinding[] = []; const resolution = indexArtifactDatasetResolution(stack); @@ -1170,6 +1194,23 @@ export function validateWidgetBindings(stack: AnyRec): WidgetBindingFinding[] { const dash = dashboards[i]; const dashName = typeof dash.name === 'string' ? dash.name : `(dashboard ${i})`; const widgets = Array.isArray(dash.widgets) ? (dash.widgets as AnyRec[]) : []; + // [#35143] No widget at all — see DASHBOARD_WITHOUT_WIDGETS for the split + // severity. Judged on an array only: a missing or malformed `widgets` is + // the schema's refusal, not this rule's. + if (Array.isArray(dash.widgets) && dash.widgets.length === 0) { + findings.push({ + severity: options?.atPublishDoor ? 'warning' : 'error', + rule: DASHBOARD_WITHOUT_WIDGETS, + where: `dashboard "${dashName}"`, + path: `dashboards[${i}].widgets`, + message: + `dashboard "${dashName}" declares no widgets, so it opens on its header over an empty canvas: there is ` + + 'nothing on it to show', + hint: + 'Add a widget bound to a dataset (`widgets: [{ id, type, dataset, values }]`), or remove the dashboard ' + + 'and any navigation entry that opens it', + }); + } // Dashboard-level filters (`dateRange` + `globalFilters`) are broadcast into // every widget's query (#2501) — resolved once here, checked per widget below. const dashFilterDefs = dashboardFilterDefs(dash); From df59db4db31000d4ff64e699d8ddf95693ae8bee Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 00:32:03 +0000 Subject: [PATCH 2/8] test(lint): pins for the views, dashboards and app shell checks Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- packages/lint/src/rule-explanations.ts | 2 +- .../lint/src/validate-app-shell-reach.test.ts | 153 ++++++++++++++++++ .../src/validate-list-view-field-refs.test.ts | 61 +++++++ .../lint/src/validate-list-view-field-refs.ts | 22 ++- .../validate-list-view-kanban-lanes.test.ts | 83 ++++++++++ ...e-security-posture.runtime-surface.test.ts | 25 ++- .../lint/src/validate-widget-bindings.test.ts | 49 ++++++ 7 files changed, 378 insertions(+), 17 deletions(-) create mode 100644 packages/lint/src/validate-app-shell-reach.test.ts diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index bc405d7cdd9..c0a5bb4298e 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -1625,7 +1625,7 @@ const OBJECT_UNREACHABLE_FROM_NAVIGATION_EXPLANATION: RuleExplanation = { const OBJECT_WITHOUT_VIEW_EXPLANATION: RuleExplanation = { rule: 'object-without-view', - covers: 'what an object opened from navigation shows without a list view', + covers: 'what an object opened from navigation shows with no view', paragraphs: [ 'An object a navigation entry opens, with no `list`, no `listViews` entry and no `views` item bound to it, ' + 'opens on an "All records" tab the console builds itself: the name field followed by `highlightFields`, ' + diff --git a/packages/lint/src/validate-app-shell-reach.test.ts b/packages/lint/src/validate-app-shell-reach.test.ts new file mode 100644 index 00000000000..4da07a4da01 --- /dev/null +++ b/packages/lint/src/validate-app-shell-reach.test.ts @@ -0,0 +1,153 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// +// [#35143] The app shell an author ships: an app with no navigation entry, an +// object no app opens, and an object navigation opens with no list view. All +// three advisory; each pinned lit and dark, through the registry and, for the +// app, at the runtime `app` door. + +import { describe, expect, it } from 'vitest'; + +import { authoringRulesFor, runAuthoringRules, splitBySeverity } from './authoring-rules.js'; +import { explainRule } from './rule-explanations.js'; +import { runRuntimeAuthoringRules, runtimeAuthoringRulesFor } from './runtime-gate.js'; +import { + APP_NAVIGATION_EMPTY, + OBJECT_UNREACHABLE_FROM_NAVIGATION, + OBJECT_WITHOUT_VIEW, + validateAppNavigationPresent, + validateObjectShellReach, +} from './validate-app-shell-reach.js'; + +type AnyRec = Record; + +const objects = [ + { name: 'crm_account', label: 'Account', fields: { name: { type: 'text' } } }, + { name: 'crm_note', label: 'Note', fields: { body: { type: 'text' } } }, +]; +const navTo = (objectName: string) => ({ id: `nav_${objectName}`, type: 'object', label: objectName, objectName }); +const accountView = { name: 'crm_account', object: 'crm_account', list: { type: 'grid', columns: ['name'] } }; + +describe('[#35143] app-navigation-empty', () => { + const findings = (apps: unknown, extra: AnyRec = {}) => + validateAppNavigationPresent({ objects, apps, ...extra }).map((f) => [f.rule, f.severity, f.path]); + + it.each([ + ['no `navigation` key', { name: 'crm', label: 'CRM' }], + ['an empty `navigation`', { name: 'crm', label: 'CRM', navigation: [] }], + ['only a separator and an empty group', { + name: 'crm', + label: 'CRM', + navigation: [{ id: 's', type: 'separator' }, { id: 'g', type: 'group', label: 'G', children: [] }], + }], + ['an area with no entry', { name: 'crm', label: 'CRM', areas: [{ id: 'a', label: 'A', navigation: [] }] }], + ])('warns on %s', (_label, app) => { + expect(findings([app])).toEqual([[APP_NAVIGATION_EMPTY, 'warning', 'apps[0].navigation']]); + }); + + it.each([ + ['a top-level entry', { name: 'crm', label: 'CRM', navigation: [navTo('crm_account')] }], + ['an entry inside a group', { + name: 'crm', + label: 'CRM', + navigation: [{ id: 'g', type: 'group', label: 'G', children: [navTo('crm_account')] }], + }], + ['an entry in an area', { name: 'crm', label: 'CRM', areas: [{ id: 'a', label: 'A', navigation: [navTo('crm_account')] }] }], + ])('is silent with %s', (_label, app) => { + expect(findings([app])).toEqual([]); + }); + + it('counts navigation this stack contributes into the app', () => { + const navigationContributions = [{ app: 'crm', items: [navTo('crm_account')] }]; + expect(findings([{ name: 'crm', label: 'CRM' }], { manifest: { id: 'p', navigationContributions } })).toEqual([]); + }); + + it('is advisory on `validate` and `build`, and the hint names the fix', () => { + for (const command of ['validate', 'build'] as const) { + const all = runAuthoringRules(command, { normalized: { objects, apps: [{ name: 'crm', label: 'CRM' }] } }); + const { errors, advisories } = splitBySeverity(all); + expect(advisories.map((f) => f.rule)).toContain(APP_NAVIGATION_EMPTY); + expect(errors.map((f) => f.rule)).not.toContain(APP_NAVIGATION_EMPTY); + } + const [f] = validateAppNavigationPresent({ apps: [{ name: 'crm', label: 'CRM' }] }); + expect(f.hint).toContain("type: 'object'"); + }); + + it('rides the runtime `app` door as an advisory, and is silent once the app has an entry', () => { + expect(runtimeAuthoringRulesFor('app').map((r) => r.name)).toContain('validateAppNavigationPresent'); + const lit = runRuntimeAuthoringRules({ type: 'app', item: { name: 'ops_desk', label: 'Ops' }, context: { objects } }); + expect(lit.errors).toEqual([]); + expect(lit.advisories.map((f) => f.rule)).toEqual([APP_NAVIGATION_EMPTY]); + const fixed = runRuntimeAuthoringRules({ + type: 'app', + item: { name: 'ops_desk', label: 'Ops', navigation: [navTo('crm_account')] }, + context: { objects }, + }); + expect(fixed.advisories.map((f) => f.rule)).not.toContain(APP_NAVIGATION_EMPTY); + }); +}); + +describe('[#35143] object-unreachable-from-navigation and object-without-view', () => { + const run = (stack: AnyRec) => validateObjectShellReach(stack).map((f) => [f.rule, f.path]); + const app = (...nav: unknown[]) => ({ name: 'crm', label: 'CRM', navigation: nav }); + + it('an object no app names is a warning at the object; one navigation opens with a view is silent', () => { + expect(run({ objects, views: [accountView], apps: [app(navTo('crm_account'))] })).toEqual([ + [OBJECT_UNREACHABLE_FROM_NAVIGATION, 'objects[1]'], + ]); + }); + + it('reach counts entries at any depth, in areas and in contributed navigation', () => { + const grouped = app({ id: 'g', type: 'group', label: 'G', children: [navTo('crm_note')] }, navTo('crm_account')); + expect(run({ objects, views: [accountView, { ...accountView, name: 'n', object: 'crm_note' }], apps: [grouped] })).toEqual([]); + const contributed = { + objects, + views: [accountView, { ...accountView, name: 'n', object: 'crm_note' }], + apps: [app(navTo('crm_account'))], + manifest: { id: 'p', navigationContributions: [{ app: 'setup', items: [navTo('crm_note')] }] }, + }; + expect(run(contributed)).toEqual([]); + }); + + it('a master-detail child and an API-disabled object are not judged; a stack with no app is not judged', () => { + const child = { name: 'crm_note', fields: { account: { type: 'master_detail', reference: 'crm_account' } } }; + const hidden = { name: 'crm_log', enable: { apiEnabled: false }, fields: { body: { type: 'text' } } }; + expect(run({ objects: [objects[0], child, hidden], views: [accountView], apps: [app(navTo('crm_account'))] })).toEqual([]); + expect(run({ objects })).toEqual([]); + }); + + it.each([ + ['an object `list`', { objects: [{ ...objects[0], list: { type: 'grid', columns: ['name'] } }] }], + ['an object `listViews` entry', { objects: [{ ...objects[0], listViews: { all: { type: 'grid', columns: ['name'] } } }] }], + ['a `views` item', { objects: [objects[0]], views: [accountView] }], + ['a flattened list overlay', { objects: [objects[0]], views: [{ name: 'a.x', object: 'crm_account', viewKind: 'list', columns: ['name'] }] }], + ])('an object opened from navigation with %s has a view', (_label, stack) => { + expect(run({ ...stack, apps: [app(navTo('crm_account'))] })).toEqual([]); + }); + + it('an object opened from navigation with no view is a warning that names the fix', () => { + const findings = validateObjectShellReach({ objects: [objects[0]], apps: [app(navTo('crm_account'))] }); + expect(findings.map((f) => [f.rule, f.severity, f.path])).toEqual([[OBJECT_WITHOUT_VIEW, 'warning', 'objects[0]']]); + expect(findings[0].message).toContain('All records'); + expect(findings[0].hint).toContain('list:'); + }); + + it('runs on all three commands as an advisory, and never at the runtime door', () => { + for (const command of ['validate', 'build', 'lint'] as const) { + expect(authoringRulesFor(command).map((r) => r.name)).toContain('validateObjectShellReach'); + const { errors, advisories } = splitBySeverity( + runAuthoringRules(command, { normalized: { objects, apps: [app(navTo('crm_account'))] } }), + ); + expect(advisories.map((f) => f.rule)).toEqual(expect.arrayContaining([OBJECT_UNREACHABLE_FROM_NAVIGATION, OBJECT_WITHOUT_VIEW])); + expect(errors.map((f) => f.rule)).not.toContain(OBJECT_WITHOUT_VIEW); + } + for (const type of ['object', 'app', 'view']) { + expect(runtimeAuthoringRulesFor(type).map((r) => r.name)).not.toContain('validateObjectShellReach'); + } + }); +}); + +describe('[#35143] `os explain` for the app-shell ids', () => { + it.each([APP_NAVIGATION_EMPTY, OBJECT_UNREACHABLE_FROM_NAVIGATION, OBJECT_WITHOUT_VIEW])('%s has an entry', (rule) => { + expect(explainRule(rule)?.paragraphs.length).toBeGreaterThan(0); + }); +}); diff --git a/packages/lint/src/validate-list-view-field-refs.test.ts b/packages/lint/src/validate-list-view-field-refs.test.ts index d738ecd55af..d6c940cf0b8 100644 --- a/packages/lint/src/validate-list-view-field-refs.test.ts +++ b/packages/lint/src/validate-list-view-field-refs.test.ts @@ -22,6 +22,7 @@ import { LIST_VIEW_CHART_DATASET_FOREIGN_OBJECT, LIST_VIEW_OBJECT_OUTSIDE_CLOSURE, LIST_VIEW_OBJECT_UNKNOWN, + LIST_VIEW_FILTER_FIELD_VIRTUAL, listViewWalkedPositions, type ListViewFieldRefFinding, } from './validate-list-view-field-refs.js'; @@ -1759,3 +1760,63 @@ describe('[#36370] the lane foot statistic of a board', () => { expect(withSummary({ type: 'none' })).toEqual([]); }); }); + +// [#35143] A list view filter keyed on a field computed on read. The engine's +// filter seam (`assertFilterIsMaterializable`) refuses the query 400 +// INVALID_FIELD, so the view opens on that error; the rule says so at publish. +describe('[#35143] a list view filter on a formula field', () => { + const virtualFindings = (listView: AnyRec) => + validateListViewFieldRefs(stackWith(listView)).filter((f) => f.rule === LIST_VIEW_FILTER_FIELD_VIRTUAL); + const on = (field: string) => [{ field, operator: 'equals', value: 1 }]; + + it('a filter on a stored field is silent', () => { + expect(virtualFindings(FULL_LIST_VIEW)).toEqual([]); + }); + + it.each([ + ['the rule-array shape', { filter: on('score') }, 'views[0].list.filter[0].field'], + ['the condition-object shape', { filter: { score: { $gt: 1 } } }, 'views[0].list.filter.score'], + ['a `userFilters.tabs[]` preset', { userFilters: { tabs: [{ name: 'hot', filter: on('score') }] } }, 'views[0].list.userFilters.tabs[0].filter[0].field'], + ])('an error in %s, naming the fix in one line', (_label, patch, path) => { + const findings = virtualFindings(mutate(patch as AnyRec)); + expect(findings.map((f) => [f.severity, f.path])).toEqual([['error', path]]); + expect(findings[0].message).toContain('400 INVALID_FIELD'); + for (const line of [findings[0].message, findings[0].hint]) { + expect(line).not.toContain('\n'); + expect(line.length, line).toBeLessThanOrEqual(200); + } + }); + + it('a dotted key whose head is a formula stays the dotted verdict, and the filter-bar field list is not judged', () => { + expect(virtualFindings(mutate({ filter: on('score.x') }))).toEqual([]); + expect(virtualFindings(mutate({ userFilters: { fields: [{ field: 'score' }] } }))).toEqual([]); + }); + + for (const command of ['validate', 'build'] as const) { + it(`fails \`${command}\``, () => { + const { errors } = splitBySeverity(runAuthoringRules(command, { normalized: stackWith(mutate({ filter: on('score') })) })); + expect(errors.map((f) => f.rule)).toContain(LIST_VIEW_FILTER_FIELD_VIRTUAL); + }); + } + + it('is refused at the runtime `view` door, and passes once the filter names a stored field', () => { + const item = (filter: unknown) => ({ name: 'duly_task', object: 'duly_task', list: mutate({ filter }) }); + const refused = runRuntimeAuthoringRules({ type: 'view', item: item(on('score')), context: { objects: OBJECTS } }); + expect(refused.errors.map((f) => f.rule)).toEqual([LIST_VIEW_FILTER_FIELD_VIRTUAL]); + const clean = runRuntimeAuthoringRules({ type: 'view', item: item(on('estimate')), context: { objects: OBJECTS } }); + expect(clean.errors).toEqual([]); + }); + + it('reaches an object write through its own `listViews` (the `object` door)', () => { + const findings = validateReferenceIntegrity( + { objects: [{ ...OBJECTS[0], listViews: { hot: { type: 'grid', columns: ['title'], filter: on('score') } } }, OBJECTS[1]] }, + { runtimeWriteType: 'object' }, + ); + expect(findings.map((f) => [f.rule, f.path])).toContainEqual([LIST_VIEW_FILTER_FIELD_VIRTUAL, 'objects[0].listViews.hot.filter[0].field']); + }); + + it('`os explain` carries the reasoning', () => { + const text = explainRule(LIST_VIEW_FILTER_FIELD_VIRTUAL)!.paragraphs.join('\n'); + for (const fact of ['400 INVALID_FIELD', 'stored field', '`list-view-field-dotted`']) expect(text, fact).toContain(fact); + }); +}); diff --git a/packages/lint/src/validate-list-view-field-refs.ts b/packages/lint/src/validate-list-view-field-refs.ts index bb533664012..d21d3822944 100644 --- a/packages/lint/src/validate-list-view-field-refs.ts +++ b/packages/lint/src/validate-list-view-field-refs.ts @@ -1477,14 +1477,13 @@ export function validateListViewFieldRefs( where: `${where} › kanban`, path: `${path}.kanban.groupByField`, message: multi - ? `the board is grouped by "${object}.${groupBy}", a multi-valued \`${type}\` field: a card holding ` + - 'several values falls into one lane named by all of them together, not into a lane per value' - : `the board is grouped by "${object}.${groupBy}", a \`${type}\` field with no fixed set of values: the ` + - 'board draws one lane per distinct value among the cards it has loaded, no lane for a value no card ' + - 'holds (so no card can be dragged there), and no lanes at all while the list is empty', + ? `"${object}.${groupBy}" is a multi-valued \`${type}\` field: a card holding several values falls into ` + + 'one lane named by all of them together' + : `"${object}.${groupBy}" is a \`${type}\` field: the board draws a lane per distinct value on its loaded ` + + 'cards, none for a value no card holds, and none on an empty list', hint: - `Group the board by a single-valued \`select\` field of "${object}" (one lane per option), a boolean or a ` + - `lookup; or show "${groupBy}" as a grid column or grouping instead of board lanes`, + `Group the board by a single-valued \`select\` (one lane per option), a boolean or a lookup, or show ` + + `"${groupBy}" as a grid grouping`, }); }; @@ -1781,12 +1780,11 @@ export function validateListViewFieldRefs( where: filterWhere, path: at, message: - `filter key "${written}" is a \`${type}\` field of "${object}": its value is computed on read and no store ` + - 'keeps a column for it, so the engine refuses the list\'s query (400 INVALID_FIELD) and the view opens on ' + - 'that error with no records', + `filter key "${written}" is a \`${type}\` field of "${object}": it has no stored column, so the engine ` + + 'refuses the list\'s query (400 INVALID_FIELD) and the view opens on that error', hint: - `Filter on the stored fields of "${object}" that the formula reads, or keep the value in a stored field ` + - `written when its sources change and filter on that; or remove the "${written}" condition`, + 'Filter on the stored fields the formula reads, or keep the value in a stored field written when its ' + + `sources change; or remove the "${written}" condition`, }); }; diff --git a/packages/lint/src/validate-list-view-kanban-lanes.test.ts b/packages/lint/src/validate-list-view-kanban-lanes.test.ts index 40031a43e95..aee06f3d800 100644 --- a/packages/lint/src/validate-list-view-kanban-lanes.test.ts +++ b/packages/lint/src/validate-list-view-kanban-lanes.test.ts @@ -13,7 +13,9 @@ import { LIST_VIEW_FIELD_UNKNOWN, LIST_VIEW_KANBAN_LANE_UNKNOWN, LIST_VIEW_KANBAN_LANE_REPEATED, + LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL, } from './validate-list-view-field-refs.js'; +import { runRuntimeAuthoringRules } from './runtime-gate.js'; import { explainRule } from './rule-explanations.js'; type AnyRec = Record; @@ -147,3 +149,84 @@ describe('#28018 — kanban.lanes judged against the group field', () => { } }); }); + +describe('#35143 — a board grouped by a field with no lanes of its own', () => { + const GROUP_OBJECTS = [ + { + name: 'crm_task', + label: 'Task', + fields: { + subject: { type: 'text', label: 'Subject' }, + status: { type: 'select', label: 'Status', options: STATUS_OPTIONS }, + stage: { type: 'radio', label: 'Stage', options: STATUS_OPTIONS }, + is_completed: { type: 'boolean', label: 'Completed' }, + owner: { type: 'lookup', label: 'Owner', reference: 'sys_user' }, + amount: { type: 'number', label: 'Amount' }, + due_date: { type: 'date', label: 'Due' }, + tags: { type: 'multiselect', label: 'Tags', options: STATUS_OPTIONS }, + watchers: { type: 'lookup', label: 'Watchers', reference: 'sys_user', multiple: true }, + }, + }, + ]; + const groupedBy = (groupByField: string, type = 'kanban'): AnyRec => ({ + ...TASK_BOARD, + type, + kanban: { groupByField, columns: ['subject'] }, + }); + const groupFindings = (listView: AnyRec) => + validateListViewFieldRefs(stackWith(listView, GROUP_OBJECTS)).filter( + (f) => f.rule === LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL, + ); + + it.each(['status', 'stage', 'is_completed', 'owner'])('a board grouped by `%s` (a fixed set of lanes) is silent', (field) => { + expect(groupFindings(groupedBy(field))).toEqual([]); + }); + + it.each([ + ['amount', 'number', 'distinct value'], + ['due_date', 'date', 'distinct value'], + ['subject', 'text', 'distinct value'], + ['tags', 'multiselect', 'multi-valued'], + ['watchers', 'lookup', 'multi-valued'], + ])('a board grouped by `%s` (a %s field) is a warning at groupByField that names the fix', (field, type, phrase) => { + const findings = groupFindings(groupedBy(field)); + expect(findings.map((f) => [f.severity, f.path])).toEqual([['warning', 'views[0].list.kanban.groupByField']]); + expect(findings[0].message).toContain(`\`${type}\``); + expect(findings[0].message).toContain(phrase); + expect(findings[0].hint).toContain('`select`'); + for (const line of [findings[0].message, findings[0].hint]) expect(line.length, line).toBeLessThanOrEqual(200); + }); + + it('a kanban block on a non-kanban view, a dotted and an unknown group field are not judged', () => { + expect(groupFindings(groupedBy('amount', 'grid'))).toEqual([]); + expect(groupFindings(groupedBy('owner.name'))).toEqual([]); + expect(groupFindings(groupedBy('nothing_here'))).toEqual([]); + }); + + for (const command of ['validate', 'build'] as const) { + it(`is advisory on \`${command}\`: reported, never an error`, () => { + const findings = runAuthoringRules(command, { normalized: stackWith(groupedBy('amount'), GROUP_OBJECTS) }); + const { errors, advisories } = splitBySeverity(findings); + expect(advisories.map((f) => f.rule)).toContain(LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL); + expect(errors.map((f) => f.rule)).not.toContain(LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL); + }); + } + + it('rides the runtime `view` door as an advisory, and is silent once grouped by a select', () => { + const item = { name: 'crm_task', object: 'crm_task', list: groupedBy('amount') }; + const lit = runRuntimeAuthoringRules({ type: 'view', item, context: { objects: GROUP_OBJECTS } }); + expect(lit.errors).toEqual([]); + expect(lit.advisories.map((f) => f.rule)).toEqual([LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL]); + const fixed = runRuntimeAuthoringRules({ + type: 'view', + item: { ...item, list: groupedBy('status') }, + context: { objects: GROUP_OBJECTS }, + }); + expect(fixed.advisories.map((f) => f.rule)).not.toContain(LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL); + }); + + it('`os explain` carries the reasoning', () => { + const text = explainRule(LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL)!.paragraphs.join('\n'); + for (const fact of ['`select`', 'multi-valued', 'dragged']) expect(text, fact).toContain(fact); + }); +}); diff --git a/packages/lint/src/validate-security-posture.runtime-surface.test.ts b/packages/lint/src/validate-security-posture.runtime-surface.test.ts index 3a7c2f2d78c..ad992d9a3d7 100644 --- a/packages/lint/src/validate-security-posture.runtime-surface.test.ts +++ b/packages/lint/src/validate-security-posture.runtime-surface.test.ts @@ -331,10 +331,16 @@ describe('validateSecurityPosture at the runtime publish surface (#7576 → #830 // wired-onto-nothing shape wearing this pin's clothes. // #28663 — `app` writes also reach the visibility-predicate family (a nav // entry's `visible` that does not parse), ahead of this rule in registry - // order; `position` reaches this rule alone. + // order; `position` reaches this rule alone. #35143 — and the advisory + // `validateAppNavigationPresent` after it. const expected: Record = { position: ['validateSecurityRoleWord'], - app: ['validateVisibilityPredicates', 'validatePredicatePathRefs', 'validateSecurityRoleWord'], + app: [ + 'validateVisibilityPredicates', + 'validatePredicatePathRefs', + 'validateSecurityRoleWord', + 'validateAppNavigationPresent', + ], }; for (const type of ['position', 'app']) { expect( @@ -512,14 +518,25 @@ describe('validateSecurityPosture at the runtime publish surface (#7576 → #830 expect(labelled.errors[0].path).toBe('apps[0].label'); // ⭐ The lit control, same job as the position one above. + // #35143 — the control carries a navigation entry, or it would draw the + // `app-navigation-empty` advisory. const clean = runRuntimeAuthoringRules({ type: 'app', - item: { name: 'ops_hub', label: 'Operations Hub' }, + item: { + name: 'ops_hub', + label: 'Operations Hub', + navigation: [{ id: 'nav_home', type: 'url', label: 'Home', url: 'https://example.com' }], + }, }); expect(clean.errors).toEqual([]); expect(clean.advisories).toEqual([]); // #28663 — the visibility-predicate family runs on an app write too. - expect(clean.rulesRun).toEqual(['validateVisibilityPredicates', 'validatePredicatePathRefs', 'validateSecurityRoleWord']); + expect(clean.rulesRun).toEqual([ + 'validateVisibilityPredicates', + 'validatePredicatePathRefs', + 'validateSecurityRoleWord', + 'validateAppNavigationPresent', + ]); }); it('[#19370] the two types already at the door gain the freeze too, with their controls', () => { diff --git a/packages/lint/src/validate-widget-bindings.test.ts b/packages/lint/src/validate-widget-bindings.test.ts index 36e982d05d5..134fecce0af 100644 --- a/packages/lint/src/validate-widget-bindings.test.ts +++ b/packages/lint/src/validate-widget-bindings.test.ts @@ -27,7 +27,9 @@ import { WIDGET_FILTER_FIELD_UNKNOWN, WIDGET_FILTER_FIELD_NOT_INCLUDED, WIDGET_SORTBY_UNSELECTED, + DASHBOARD_WITHOUT_WIDGETS, } from './validate-widget-bindings.js'; +import { runRuntimeAuthoringRules } from './runtime-gate.js'; import { explainRule } from './rule-explanations.js'; // [#22161] Each finding of the rule ids this file's rule shortened is one @@ -2337,3 +2339,50 @@ describe('[#22161] one-line fix — the rule ids whose `fix:` line this file sho for (const fact of MOVED_FROM_HINT[rule]) expect(text, `${rule} explanation names ${fact}`).toContain(fact); }); }); + +// [#35143] A dashboard with no widgets publishes and opens on its header over +// an empty canvas. An error on the CLI; a warning at the runtime door, where +// Studio creates a dashboard with `widgets: []` and fills it afterwards. +describe('[#35143] a dashboard with no widgets', () => { + const EMPTY = { name: 'ops_board', label: 'Ops', widgets: [] }; + const datasets = [{ name: 'task_stats', object: 'task', measures: [{ name: 'n', aggregate: 'count' }] }]; + const objects = [{ name: 'task', fields: { title: { type: 'text' } } }]; + const FILLED = { + ...EMPTY, + widgets: [{ id: 'w1', type: 'metric', dataset: 'task_stats', values: ['n'], layout: { x: 0, y: 0, w: 3, h: 2 } }], + }; + const emptyFindings = (stack: Record, atPublishDoor?: boolean) => + validateWidgetBindingsUnrecorded(stack, { atPublishDoor }).filter((f) => f.rule === DASHBOARD_WITHOUT_WIDGETS); + + it('is an error at `widgets` on the CLI, naming the fix', () => { + const findings = emptyFindings({ objects, datasets, dashboards: [EMPTY] }); + expect(findings.map((f) => [f.severity, f.path])).toEqual([['error', 'dashboards[0].widgets']]); + expect(findings[0].hint).toContain('Add a widget'); + }); + + it('is silent on a dashboard with a widget, and on one with no `widgets` array (the schema refuses that)', () => { + expect(emptyFindings({ objects, datasets, dashboards: [FILLED] })).toEqual([]); + expect(emptyFindings({ objects, datasets, dashboards: [{ name: 'x', label: 'X' }] })).toEqual([]); + }); + + for (const command of ['validate', 'build'] as const) { + it(`fails \`${command}\``, () => { + const { errors } = splitBySeverity(runAuthoringRules(command, { normalized: { objects, datasets, dashboards: [EMPTY] } })); + expect(errors.map((f) => f.rule)).toContain(DASHBOARD_WITHOUT_WIDGETS); + }); + } + + it('is an advisory at the runtime `dashboard` door, never a refusal, and silent once a widget is added', () => { + const empty = runRuntimeAuthoringRules({ type: 'dashboard', item: EMPTY, context: { objects, datasets } }); + expect(empty.errors).toEqual([]); + expect(empty.advisories.map((f) => f.rule)).toEqual([DASHBOARD_WITHOUT_WIDGETS]); + const filled = runRuntimeAuthoringRules({ type: 'dashboard', item: FILLED, context: { objects, datasets } }); + expect(filled.errors).toEqual([]); + expect(filled.advisories.map((f) => f.rule)).not.toContain(DASHBOARD_WITHOUT_WIDGETS); + }); + + it('`os explain` carries the split severity', () => { + const text = explainRule(DASHBOARD_WITHOUT_WIDGETS)!.paragraphs.join('\n'); + for (const fact of ['`widgets: []`', 'runtime publish door', 'Studio']) expect(text, fact).toContain(fact); + }); +}); From 7f6180adbaa7935352652ddad3aff44b22b58930 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 00:33:32 +0000 Subject: [PATCH 3/8] docs: the views, dashboards and app shell rules in the rule table, the changeset and the upgrade-guide entry Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- .changeset/35143-views-dashboards-checks.md | 26 +++++++++++++++ content/docs/deployment/cli.mdx | 2 +- .../docs/deployment/validating-metadata.mdx | 8 +++-- .../build-with-claude-code.mdx | 2 +- content/docs/ui/react-pages.mdx | 2 +- ...nd-dashboards-that-save-and-do-not-work.ts | 33 +++++++++++++++++++ 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 .changeset/35143-views-dashboards-checks.md create mode 100644 packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts diff --git a/.changeset/35143-views-dashboards-checks.md b/.changeset/35143-views-dashboards-checks.md new file mode 100644 index 00000000000..064dc9c8da6 --- /dev/null +++ b/.changeset/35143-views-dashboards-checks.md @@ -0,0 +1,26 @@ +--- +'@objectstack/lint': minor +'@objectstack/spec': patch +--- + +fix(lint)!: publish-time checks for views, dashboards and the app shell that save and do not work + +Clause-②: no (narrowing) +Metadata-protocol: narrowed + + + +**BREAKING** for a list view filter keyed on a `formula` field and for a packaged dashboard with no widgets: both were accepted before and are refused now, with the fix named in the finding. The schema is unchanged and stored metadata is not rewritten or refused at boot; the refusal comes at the next publish, and from `os validate` / `lint` / `compile` / `build`. + +- `list-view-filter-field-virtual` (error): a list view's own `filter`, or a `userFilters.tabs[]` preset, keyed on a field computed on read (`formula`). The engine refuses every query filtered on such a field (`400 INVALID_FIELD`), so the view opens on that error every time. Refused at the runtime publish door on a `view` write and on an `object` write through the object's own `listViews`. A dotted key whose head is a formula stays `list-view-field-dotted`; the filter bar's field list (`userFilters.fields`) is not judged. +- `dashboard-without-widgets`: a dashboard with `widgets: []`, which opens on its header over an empty canvas. An error on `os validate` / `lint` / `build`; a warning at the runtime publish door, because Studio's own create paths save a new dashboard with `widgets: []` and fill it afterwards. +- `list-view-kanban-group-field-uncategorical` (warning): a `kanban` board grouped by a field with no fixed set of lanes. A text, number or date field gets one lane per distinct value on the loaded cards and no lane for a value no card holds; a multi-valued field puts a card holding several values in one lane named by all of them. A `select` / `radio`, a boolean and a single-valued reference are silent. Runs on the runtime `view` and `object` doors. +- `app-navigation-empty` (warning): an app with no entry in `navigation` nor in any `areas[].navigation` (a separator or an empty group counts as nothing), and no navigation the stack contributes into it. It opens on the "no access" empty state for every member. Runs on the runtime `app` door. +- `object-unreachable-from-navigation` and `object-without-view` (warnings, `os validate` / `lint` / `build` only): an object no app's navigation opens (a `master_detail` child and an API-disabled object are not judged, nor a stack with no app), and an object navigation opens that declares no list view, which then opens on the console's own "All records" tab. + +## FROM → TO + +- `filter: [{ field: 'is_overdue', operator: 'equals', value: true }]` where `is_overdue` is a `formula` → `filter: [{ field: 'due_date', operator: 'lt', value: '{today}' }]` (the stored field the formula reads), or a stored field written when its sources change. +- `{ name: 'ops', label: 'Ops', widgets: [] }` → add a widget bound to a dataset, or remove the dashboard. + +`@objectstack/lint` exports six rule id constants (`LIST_VIEW_FILTER_FIELD_VIRTUAL`, `LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL`, `DASHBOARD_WITHOUT_WIDGETS`, `APP_NAVIGATION_EMPTY`, `OBJECT_UNREACHABLE_FROM_NAVIGATION`, `OBJECT_WITHOUT_VIEW`) so `os explain` carries an entry for each; the two new rules are not exported. `validateWidgetBindings` takes an optional second argument (`{ atPublishDoor }`). `@objectstack/spec` adds only the upgrade-guide entry `publish-refuses-views-and-dashboards-that-save-and-do-not-work`. diff --git a/content/docs/deployment/cli.mdx b/content/docs/deployment/cli.mdx index 2b316444236..373a82ffe85 100644 --- a/content/docs/deployment/cli.mdx +++ b/content/docs/deployment/cli.mdx @@ -937,7 +937,7 @@ os compile --json # JSON output for CI pipelines → Normalizing stack definition... → Lowering inline handlers... → Validating protocol compliance... - → Running author-time rules (86)... + → Running author-time rules (88)... → Checking that every required capability has a provider installable in this edition... → Collecting package docs (ADR-0046)... 0 collected → Writing artifact... diff --git a/content/docs/deployment/validating-metadata.mdx b/content/docs/deployment/validating-metadata.mdx index 72c0ea627a1..151977154fb 100644 --- a/content/docs/deployment/validating-metadata.mdx +++ b/content/docs/deployment/validating-metadata.mdx @@ -500,7 +500,7 @@ orthogonal to both, and no cell here can carry it; it is written out in | Retired object title template — an object that declares `titleFormat`, retired by ADR-0079 for `nameField` (`title-format-retired`, #29007) | ✓ | ✓ | ✓ | ✓ᵒ | | Roll-up aggregands — a `summaryOperations` `min` / `max` whose answer is not a number, or a `sum` / `avg` over a child field type the aggregate × field-type table refuses (`rollup/non-numeric-aggregand`) | ✓ | ✓ | ✓ | ✓ᵒ | | View container shape | ✓ | ✓ | ✓ | — | -| Widget-binding integrity (ADR-0021) | ✓ | ✓ | ✓ | ✓ᵈ | +| Widget-binding integrity (ADR-0021) — and a dashboard with no widgets, which opens on its header over an empty canvas (`dashboard-without-widgets`, #35143): an error on the CLI and a warning at the publish door, where Studio creates a dashboard empty and fills it afterwards | ✓ | ✓ | ✓ | ✓ᵈ | | Dataset measure `aggregate` × the field's declared type — a pair the spec's compatibility table refuses, e.g. `avg` over a `datetime` field (#16354) | ✓ | ✓ | ✓ | ✓ᵈᵗ | | Dashboard action/route references (ADR-0049) | ✓ | ✓ | ✓ | — | | Filter placeholder resolvability (#3574) | ✓ | ✓ | ✓ | — | @@ -508,11 +508,13 @@ orthogonal to both, and no cell here can carry it; it is written out in | Empty filter combinators — `$and: []`, `$or: []`, `$not: {}` (#5330) | ✓ | ✓ | ✓ | ✓ᶠʳ | | Object & action name references (#3583) — and the object a seed dataset, a flow `get_record` / `create_record` / `update_record` / `delete_record` / object-form `screen` node or a standalone action is bound to (`object-reference-unknown`, #35143); a flow node's miss is a warning on the CLI, where a declared dependency may define the object, and an error at the publish door; at the publish door a seed over an unknown object is the save door's own refusal (#34864) | ✓ | ✓ | ✓ | ✓ᶠᵈᵗᵃᶜ | | Reference integrity — flow node writes, template paths, read-only writes (#3583); at the publish door each write type runs only the members that declare it, and the flow members run on `flow` alone (#9313) | ✓ | ✓ | ✓ | ✓ᶠᵛᵒᵈᵗʳᵖᵃᶜ | -| List-view field members — a list view's `sort` (a `sortable: false` field, a `formula`, an unknown name: `sort-field-unsortable`), its `searchableFields` (`searchable-field-unknown`) and its field references, columns, filter keys, grouping and the board bindings (`list-view-field-unknown`); the row merges three members, so its codes follow no one rule's order, and the `page` door runs the sort member only (#9313, #15495, #30095) | ✓ | ✓ | ✓ | ✓ᶠᵛᵒᵖ | +| List-view field members — a list view's `sort` (a `sortable: false` field, a `formula`, an unknown name: `sort-field-unsortable`), its `searchableFields` (`searchable-field-unknown`) and its field references, columns, filter keys, grouping and the board bindings (`list-view-field-unknown`); a filter key on a `formula` field, which the engine refuses to filter by (`list-view-filter-field-virtual`, #35143), and, advisory, a board grouped by a field with no fixed set of lanes (`list-view-kanban-group-field-uncategorical`, #35143); the row merges three members, so its codes follow no one rule's order, and the `page` door runs the sort member only (#9313, #15495, #30095) | ✓ | ✓ | ✓ | ✓ᶠᵛᵒᵖ | | Page-component field bindings (#3583) | ✓ | ✓ | ✓ | ✓ᶠ | | React page block field bindings — §10 (#4340) | ✓ | ✓ | ✓ | ✓ᶠ | | Chart bindings outside dashboards (#3583) | ✓ | ✓ | ✓ | ✓ᶠʳᵛᵒ | | Navigation vs. granted access (ADR-0090 D6) | ✓ | ✓ | ✓ | ✓ᶠ | +| App shell, advisory — an app with no navigation entry, which opens on the "no access" empty state (`app-navigation-empty`, #35143) | ✓ | ✓ | ✓ | ✓ᵃ | +| App shell reach, advisory — an object no app's navigation opens (`object-unreachable-from-navigation`) and an object navigation opens with no list view (`object-without-view`, #35143); they read every app, view and object of the stack, which no per-write snapshot carries | ✓ | ✓ | ✓ | — | | SDUI scoped styling (ADR-0065) | ✓ | ✓ | ✓ | — | | SDUI component props — every `ComponentPropsMap` verdict: an undeclared prop, a value its props schema rejects, a missing `dataSource.object` binding, and a retired prop (`retiredKey()`) refused with its prescription (#23026, #23147; at the save door #23388) | ✓ | ✓ | ✓ | ✓ᵖ | | Page component types inside a spec-reserved namespace — a type the platform does not declare, e.g. `global:serch` (`component-type-unknown`, ADR-0078; at the save door #23388) | ✓ | ✓ | ✓ | ✓ᵖ | @@ -870,7 +872,7 @@ A clean run walks the registry and reports timing: Config: /path/to/support-desk/objectstack.config.ts Load time: 21ms → Validating against ObjectStack Protocol... - → Running author-time rules (86)... + → Running author-time rules (88)... → Checking that every required capability has a provider installable in this edition... → Checking package docs (ADR-0046)... diff --git a/content/docs/getting-started/build-with-claude-code.mdx b/content/docs/getting-started/build-with-claude-code.mdx index e6e21789448..0a0ff0aeffe 100644 --- a/content/docs/getting-started/build-with-claude-code.mdx +++ b/content/docs/getting-started/build-with-claude-code.mdx @@ -318,7 +318,7 @@ visible: 'status != "resolved"' ◆ Validate ──────────────────────────────────────── → Validating against ObjectStack Protocol... - → Running author-time rules (86)... + → Running author-time rules (88)... ✗ Author-time rules failed (1 issue) • stack · action 'resolve_ticket' visible: bare reference `status` — a diff --git a/content/docs/ui/react-pages.mdx b/content/docs/ui/react-pages.mdx index 7d50343038e..356c9c053ae 100644 --- a/content/docs/ui/react-pages.mdx +++ b/content/docs/ui/react-pages.mdx @@ -404,7 +404,7 @@ objectstack validate ──────────────────────────────────────── → Loading configuration... → Validating against ObjectStack Protocol... - → Running author-time rules (86)... + → Running author-time rules (88)... → Checking that every required capability has a provider installable in this edition... → Checking package docs (ADR-0046)... diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts new file mode 100644 index 00000000000..874ab25e854 --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts @@ -0,0 +1,33 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// The upgrade-guide entry of the Views, dashboards and app shell family of the +// second batch of author-time rules (#35143): a list view filter or a dashboard +// the schema still accepts but that shows nothing, refused at publish and in +// `os validate` / `build`, and four advisories on the app shell. Notice only: +// no key is removed and no D2 conversion exists, because each fix is a choice +// only the author can make (which stored field to filter on, which widget to +// add). +export const entry: SemanticMigration = { + id: 'publish-refuses-views-and-dashboards-that-save-and-do-not-work', + surface: + 'Two author-time errors, run by `os validate` / `lint` / `compile` / `build`: a list view filter, or a ' + + '`userFilters.tabs[]` preset, keyed on a `formula` field (`list-view-filter-field-virtual`, also refused by ' + + 'the runtime publish gate on a `view` or `object` write); and a dashboard with `widgets: []` ' + + '(`dashboard-without-widgets`, a warning at the runtime publish gate, where Studio creates a dashboard empty). ' + + 'Four warnings: a `kanban` board grouped by a field with no fixed set of lanes ' + + '(`list-view-kanban-group-field-uncategorical`), an app with no navigation entry (`app-navigation-empty`), an ' + + 'object no app\'s navigation opens (`object-unreachable-from-navigation`) and an object navigation opens with ' + + 'no list view (`object-without-view`)', + replacement: + 'Filter on the stored fields the formula reads, or on a stored field written when its sources change; add a ' + + 'widget bound to a dataset, or remove the dashboard', + reason: + 'Each parses and publishes, then shows nothing: the engine refuses a query filtered on a field computed on read ' + + '(400 INVALID_FIELD), so the view opens on that error every time; a dashboard with no widgets opens on its ' + + 'header over an empty canvas. Stored metadata is not rewritten or refused at boot. The next publish of a view ' + + 'or object carrying such a filter is refused with the fix named; the warnings never refuse.', + acceptanceCriteria: + 'os validate reports neither error; a publish of every view and object the package carries succeeds.', +}; From e6112e7577560c442f94d8eb21297b0261af2eaf Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 00:35:46 +0000 Subject: [PATCH 4/8] fix(lint): judge app-shell reach on the stack, counting navigation every package of an artifact contributes Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- .../lint/src/validate-app-shell-reach.test.ts | 13 ++++++++ packages/lint/src/validate-app-shell-reach.ts | 32 +++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/lint/src/validate-app-shell-reach.test.ts b/packages/lint/src/validate-app-shell-reach.test.ts index 4da07a4da01..253b60faaae 100644 --- a/packages/lint/src/validate-app-shell-reach.test.ts +++ b/packages/lint/src/validate-app-shell-reach.test.ts @@ -108,6 +108,19 @@ describe('[#35143] object-unreachable-from-navigation and object-without-view', expect(run(contributed)).toEqual([]); }); + it('in an assembled artifact, navigation a package contributes counts, and package objects are left to the per-package run', () => { + const artifact = { + objects: [objects[0]], + views: [accountView], + packages: [ + { manifest: { id: 'orders', navigationContributions: [{ app: 'crm', items: [navTo('crm_account')] }] } }, + { manifest: { id: 'core', apps: [app()], objects: [objects[1]] } }, + ], + }; + expect(run(artifact)).toEqual([]); + expect(validateAppNavigationPresent(artifact)).toEqual([]); + }); + it('a master-detail child and an API-disabled object are not judged; a stack with no app is not judged', () => { const child = { name: 'crm_note', fields: { account: { type: 'master_detail', reference: 'crm_account' } } }; const hidden = { name: 'crm_log', enable: { apiEnabled: false }, fields: { body: { type: 'text' } } }; diff --git a/packages/lint/src/validate-app-shell-reach.ts b/packages/lint/src/validate-app-shell-reach.ts index 6243e2360f8..831391fd81b 100644 --- a/packages/lint/src/validate-app-shell-reach.ts +++ b/packages/lint/src/validate-app-shell-reach.ts @@ -94,15 +94,30 @@ function collectNavObjects(items: unknown, into: Set): void { } } -/** One collection holder: the stack itself, then each `packages[].manifest` body. */ +/** One collection holder: the stack itself, or one `packages[].manifest` body. */ interface Holder { body: AnyRec; /** Path prefix of the holder, `''` for the stack itself. */ prefix: string; } -function holdersOf(stack: AnyRec): Holder[] { - const holders: Holder[] = [{ body: stack, prefix: '' }]; +/** + * The holders whose apps and objects are JUDGED: the stack itself only. An + * assembled artifact's `packages[]` is judged by the CLI's per-package run + * (`runPerPackageAuthoringRules`), which hands each package to these rules as + * a stack of its own; judging it here too would report each item twice. + */ +function judgedHolders(stack: AnyRec): Holder[] { + return [{ body: stack, prefix: '' }]; +} + +/** + * The holders whose navigation COUNTS toward reach: the stack and every + * package of an assembled artifact, so an entry one package contributes into + * another's app reaches the object wherever the object is judged. + */ +function reachHolders(stack: AnyRec): Holder[] { + const holders = judgedHolders(stack); packagesOf(stack).forEach((entry, i) => { if (isRec(entry.manifest)) holders.push({ body: entry.manifest, prefix: `packages[${i}].manifest.` }); }); @@ -151,9 +166,8 @@ function contributedAppNames(holders: readonly Holder[]): Set { export function validateAppNavigationPresent(stack: AnyRec): AppShellReachFinding[] { const findings: AppShellReachFinding[] = []; if (!isRec(stack)) return findings; - const holders = holdersOf(stack); - const contributed = contributedAppNames(holders); - for (const holder of holders) { + const contributed = contributedAppNames(reachHolders(stack)); + for (const holder of judgedHolders(stack)) { for (const { app, path, name } of appsOf(holder)) { if (hasEntry(app.navigation)) continue; if (recordsOf(app.areas).some((area) => hasEntry(area.navigation))) continue; @@ -196,12 +210,12 @@ function hasMasterDetailField(obj: AnyRec): boolean { /** * `object-unreachable-from-navigation` and `object-without-view` over every - * object the stack (and each package of an assembled artifact) declares. + * object the stack declares. */ export function validateObjectShellReach(stack: AnyRec): AppShellReachFinding[] { const findings: AppShellReachFinding[] = []; if (!isRec(stack)) return findings; - const holders = holdersOf(stack); + const holders = reachHolders(stack); const reached = new Set(); let navigates = false; @@ -220,7 +234,7 @@ export function validateObjectShellReach(stack: AnyRec): AppShellReachFinding[] const views = holders.flatMap((holder) => recordsOf(holder.body.views)); - for (const holder of holders) { + for (const holder of judgedHolders(stack)) { const objects = holder.body.objects; if (!Array.isArray(objects)) continue; objects.forEach((obj, i) => { From cc6ab62a7f42c5fa83b6a57b0fb774b767453dda Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 03:05:10 +0000 Subject: [PATCH 5/8] fix(lint): app-shell reach claims only what it read; an empty dashboard is advisory at every door - dashboard-without-widgets is a warning on the CLI as at the publish door; validateWidgetBindings takes no options argument again. - object-unreachable-from-navigation does not judge an object another object names in relatedLists, nor one a page that navigation opens names; its message says only that no navigation entry opens the list. - object-without-view reads ObjectSchema.listViews (the dead `list` read is gone), names listViews in its hint, and is judged only for an entry that opens a list (no recordId). - The scaffold gates e2e answers the app shell as the starter app's header tells the author to, and carries the dashboard scaffold's own advisory. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- .changeset/35143-views-dashboards-checks.md | 11 +- .../docs/deployment/validating-metadata.mdx | 4 +- .../test/generate-scaffold-gates.e2e.test.ts | 136 +++++++++++- packages/lint/src/authoring-rules.ts | 6 +- packages/lint/src/rule-explanations.ts | 25 ++- .../lint/src/validate-app-shell-reach.test.ts | 27 ++- packages/lint/src/validate-app-shell-reach.ts | 205 +++++++++++------- .../lint/src/validate-widget-bindings.test.ts | 27 ++- packages/lint/src/validate-widget-bindings.ts | 32 +-- ...nd-dashboards-that-save-and-do-not-work.ts | 30 ++- 10 files changed, 340 insertions(+), 163 deletions(-) diff --git a/.changeset/35143-views-dashboards-checks.md b/.changeset/35143-views-dashboards-checks.md index 064dc9c8da6..d05fbff53db 100644 --- a/.changeset/35143-views-dashboards-checks.md +++ b/.changeset/35143-views-dashboards-checks.md @@ -5,22 +5,21 @@ fix(lint)!: publish-time checks for views, dashboards and the app shell that save and do not work -Clause-②: no (narrowing) +Clause-②: yes (narrowing) Metadata-protocol: narrowed -**BREAKING** for a list view filter keyed on a `formula` field and for a packaged dashboard with no widgets: both were accepted before and are refused now, with the fix named in the finding. The schema is unchanged and stored metadata is not rewritten or refused at boot; the refusal comes at the next publish, and from `os validate` / `lint` / `compile` / `build`. +**BREAKING** for a list view filter keyed on a `formula` field: it was accepted before and is refused now, with the fix named in the finding. The schema is unchanged and stored metadata is not rewritten or refused at boot; the refusal comes at the next publish, and from `os validate` / `lint` / `compile` / `build`. - `list-view-filter-field-virtual` (error): a list view's own `filter`, or a `userFilters.tabs[]` preset, keyed on a field computed on read (`formula`). The engine refuses every query filtered on such a field (`400 INVALID_FIELD`), so the view opens on that error every time. Refused at the runtime publish door on a `view` write and on an `object` write through the object's own `listViews`. A dotted key whose head is a formula stays `list-view-field-dotted`; the filter bar's field list (`userFilters.fields`) is not judged. -- `dashboard-without-widgets`: a dashboard with `widgets: []`, which opens on its header over an empty canvas. An error on `os validate` / `lint` / `build`; a warning at the runtime publish door, because Studio's own create paths save a new dashboard with `widgets: []` and fill it afterwards. +- `dashboard-without-widgets` (warning, every door): a dashboard with `widgets: []`, which opens on its header over an empty canvas. Advisory because the shape breaks no request and the platform's own create steps (Studio, the spec's create seed, `os generate dashboard`) write it and fill it afterwards. - `list-view-kanban-group-field-uncategorical` (warning): a `kanban` board grouped by a field with no fixed set of lanes. A text, number or date field gets one lane per distinct value on the loaded cards and no lane for a value no card holds; a multi-valued field puts a card holding several values in one lane named by all of them. A `select` / `radio`, a boolean and a single-valued reference are silent. Runs on the runtime `view` and `object` doors. - `app-navigation-empty` (warning): an app with no entry in `navigation` nor in any `areas[].navigation` (a separator or an empty group counts as nothing), and no navigation the stack contributes into it. It opens on the "no access" empty state for every member. Runs on the runtime `app` door. -- `object-unreachable-from-navigation` and `object-without-view` (warnings, `os validate` / `lint` / `build` only): an object no app's navigation opens (a `master_detail` child and an API-disabled object are not judged, nor a stack with no app), and an object navigation opens that declares no list view, which then opens on the console's own "All records" tab. +- `object-unreachable-from-navigation` and `object-without-view` (warnings, `os validate` / `lint` / `build` only): an object no navigation entry opens (not judged: a `master_detail` child, an object another object names in `relatedLists`, an object a page names when navigation opens that page, an API-disabled object, and a stack with no app), and an object navigation opens as a list that declares no `listViews` entry and no bound `views` item, which then opens on the console's own "All records" tab. Fix: `listViews: { all: { type: 'grid', columns: [...] } }` on the object, or a `views` entry bound to it. ## FROM → TO - `filter: [{ field: 'is_overdue', operator: 'equals', value: true }]` where `is_overdue` is a `formula` → `filter: [{ field: 'due_date', operator: 'lt', value: '{today}' }]` (the stored field the formula reads), or a stored field written when its sources change. -- `{ name: 'ops', label: 'Ops', widgets: [] }` → add a widget bound to a dataset, or remove the dashboard. -`@objectstack/lint` exports six rule id constants (`LIST_VIEW_FILTER_FIELD_VIRTUAL`, `LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL`, `DASHBOARD_WITHOUT_WIDGETS`, `APP_NAVIGATION_EMPTY`, `OBJECT_UNREACHABLE_FROM_NAVIGATION`, `OBJECT_WITHOUT_VIEW`) so `os explain` carries an entry for each; the two new rules are not exported. `validateWidgetBindings` takes an optional second argument (`{ atPublishDoor }`). `@objectstack/spec` adds only the upgrade-guide entry `publish-refuses-views-and-dashboards-that-save-and-do-not-work`. +`@objectstack/lint` exports six rule id constants (`LIST_VIEW_FILTER_FIELD_VIRTUAL`, `LIST_VIEW_KANBAN_GROUP_FIELD_UNCATEGORICAL`, `DASHBOARD_WITHOUT_WIDGETS`, `APP_NAVIGATION_EMPTY`, `OBJECT_UNREACHABLE_FROM_NAVIGATION`, `OBJECT_WITHOUT_VIEW`) so `os explain` carries an entry for each; the two new rule functions are not exported. `@objectstack/spec` adds only the upgrade-guide entry `publish-refuses-views-and-dashboards-that-save-and-do-not-work`. diff --git a/content/docs/deployment/validating-metadata.mdx b/content/docs/deployment/validating-metadata.mdx index 054c580f676..e8b85d0c807 100644 --- a/content/docs/deployment/validating-metadata.mdx +++ b/content/docs/deployment/validating-metadata.mdx @@ -500,7 +500,7 @@ orthogonal to both, and no cell here can carry it; it is written out in | Retired object title template — an object that declares `titleFormat`, retired by ADR-0079 for `nameField` (`title-format-retired`, #29007) | ✓ | ✓ | ✓ | ✓ᵒ | | Roll-up aggregands — a `summaryOperations` `min` / `max` whose answer is not a number, or a `sum` / `avg` over a child field type the aggregate × field-type table refuses (`rollup/non-numeric-aggregand`) | ✓ | ✓ | ✓ | ✓ᵒ | | View container shape | ✓ | ✓ | ✓ | — | -| Widget-binding integrity (ADR-0021) — and a dashboard with no widgets, which opens on its header over an empty canvas (`dashboard-without-widgets`, #35143): an error on the CLI and a warning at the publish door, where Studio creates a dashboard empty and fills it afterwards | ✓ | ✓ | ✓ | ✓ᵈ | +| Widget-binding integrity (ADR-0021) — and a dashboard with no widgets, which opens on its header over an empty canvas (`dashboard-without-widgets`, #35143): a warning at every door, since Studio, the create seed and `os generate dashboard` write it empty and fill it afterwards | ✓ | ✓ | ✓ | ✓ᵈ | | Dataset measure `aggregate` × the field's declared type — a pair the spec's compatibility table refuses, e.g. `avg` over a `datetime` field (#16354) | ✓ | ✓ | ✓ | ✓ᵈᵗ | | Dashboard action/route references (ADR-0049) | ✓ | ✓ | ✓ | — | | Filter placeholder resolvability (#3574) | ✓ | ✓ | ✓ | — | @@ -514,7 +514,7 @@ orthogonal to both, and no cell here can carry it; it is written out in | Chart bindings outside dashboards (#3583) | ✓ | ✓ | ✓ | ✓ᶠʳᵛᵒ | | Navigation vs. granted access (ADR-0090 D6) | ✓ | ✓ | ✓ | ✓ᶠ | | App shell, advisory — an app with no navigation entry, which opens on the "no access" empty state (`app-navigation-empty`, #35143) | ✓ | ✓ | ✓ | ✓ᵃ | -| App shell reach, advisory — an object no app's navigation opens (`object-unreachable-from-navigation`) and an object navigation opens with no list view (`object-without-view`, #35143); they read every app, view and object of the stack, which no per-write snapshot carries | ✓ | ✓ | ✓ | — | +| App shell reach, advisory — an object no navigation entry, navigated page or parent's `relatedLists` shows (`object-unreachable-from-navigation`) and an object navigation opens as a list with no `listViews` entry or bound view (`object-without-view`, #35143); they read every app, view and object of the stack, which no per-write snapshot carries | ✓ | ✓ | ✓ | — | | SDUI scoped styling (ADR-0065) | ✓ | ✓ | ✓ | — | | SDUI component props — every `ComponentPropsMap` verdict: an undeclared prop, a value its props schema rejects, a missing `dataSource.object` binding, and a retired prop (`retiredKey()`) refused with its prescription (#23026, #23147; at the save door #23388) | ✓ | ✓ | ✓ | ✓ᵖ | | Page component types inside a spec-reserved namespace — a type the platform does not declare, e.g. `global:serch` (`component-type-unknown`, ADR-0078; at the save door #23388) | ✓ | ✓ | ✓ | ✓ᵖ | diff --git a/packages/cli/test/generate-scaffold-gates.e2e.test.ts b/packages/cli/test/generate-scaffold-gates.e2e.test.ts index def22647171..e3b88e5c9ed 100644 --- a/packages/cli/test/generate-scaffold-gates.e2e.test.ts +++ b/packages/cli/test/generate-scaffold-gates.e2e.test.ts @@ -62,6 +62,26 @@ * Both expectations are read off the bare starter's own build, and each must * still hold there — so the PR that changes the starter turns this file red. * + * ## The app shell the scaffold leaves the author to finish (#35143) + * + * The starter app lists the starter's objects, and its header tells the author + * what a new one needs: "add a navigation entry for it below … and give it a + * list view — `objectstack generate view OBJECT` writes one". `os g` edits no + * app (#32153), so an object a leg generates is one no navigation entry opens, + * and `object-unreachable-from-navigation` says so. That finding is true and + * the author's to answer, exactly as `nav-object-ungranted` is above, so it is + * ⛔ not a ledger line: every leg pins that it fires on objects the leg + * generated and on none the starter declares, then answers it as the header + * says — the entry the hint names goes into the app, and `os g view` for an + * object that then reports `object-without-view` — before the three gates run. + * + * One finding is the scaffold's own, and is carried, not answered: + * `os g dashboard` writes `widgets: []` under a comment that says the + * dashboard has nothing to draw until a widget names a dataset, and which + * numbers it shows is the author's to say. `dashboard-without-widgets` is that + * comment as a finding; {@link SCAFFOLD_ADVISORIES} carries it for the one + * generator that writes it, pinned to fire exactly there. + * * ## The starter ledger — EMPTY since #21370, and shrink-only * * A bare starter can be clean without being clean: `field-no-consumers` stays @@ -97,7 +117,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { execFile } from 'node:child_process'; -import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync } from 'node:fs'; +import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; import { join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { GENERATOR_SCAFFOLD_TARGETS } from '../src/commands/generate.js'; @@ -128,6 +148,21 @@ const PREREQUISITE_STEM: Record = { object: 'gate_target', flow: */ const STARTER_LATENT_FINDINGS: Record = {}; +/** + * [#35143] The advisory a generator's own output raises, by generator, with + * the reason it is carried rather than answered. Each must fire in its leg at + * every gate and nowhere else, or this file is red. + */ +const SCAFFOLD_ADVISORIES: Record = { + dashboard: { + finding: 'dashboard-without-widgets@dashboards[0].widgets', + reason: + 'the scaffold writes an empty canvas under a comment naming the widget shape; a widget needs a dataset ' + + 'and measures only the author can choose, so the generator cannot fill it', + }, +}; +const scaffoldAdvisory = (kind: string, finding: string) => SCAFFOLD_ADVISORIES[kind]?.finding === finding; + /** * [#32393] The generator the bare starter refuses: the starter ships the one * app a package of manifest type 'app' may hold (ADR-0019 D3). See the header. @@ -258,6 +293,8 @@ interface Leg { * after the chain and BEFORE the starter's listed objects are granted. */ wake?: { run: Run; findings: string[] | null }; + /** [#35143] The objects the app-shell answer covered, by rule. */ + shell: { unreachable: string[]; withoutView: string[]; steps: { args: string[]; run: Run }[] }; gates: Record; } @@ -291,6 +328,49 @@ const grantFor = (objectName: string) => [ '--object', objectName, ]; +/** The object a `object "NAME"` finding locates, from its `where`. */ +const objectOfWhere = (where: unknown) => /^object "([^"]+)"$/.exec(String(where))?.[1]; + +/** + * [#35143] Answer the app shell as the starter app's header tells the author + * to: an entry in the app for every object no entry opens, then `os g view` + * for every object that entry opened with no list view. Returns the objects + * answered under each rule, read off `os validate --json`. + */ +async function answerAppShell(dir: string, ns: string): Promise<{ unreachable: string[]; withoutView: string[]; steps: { args: string[]; run: Run }[] }> { + const read = async (rule: string) => { + const r = await os(['validate', '--json'], dir); + let body: AnyRec = {}; + try { + body = JSON.parse(r.stdout) as AnyRec; + } catch { + throw new Error(`os validate --json printed no JSON:\n${out(r)}`); + } + return [body.errors, body.warnings] + .flatMap((l) => (Array.isArray(l) ? (l as AnyRec[]) : [])) + .filter((f) => f.rule === rule) + .map((f) => objectOfWhere(f.where)) + .filter((n): n is string => !!n); + }; + const unreachable = await read('object-unreachable-from-navigation'); + if (unreachable.length > 0) { + const appsDir = join(dir, 'src', 'apps'); + const [appFile] = readdirSync(appsDir).filter((f) => f.endsWith('.app.ts')); + if (!appFile) throw new Error(`no app file under ${appsDir} to add an entry to`); + const source = readFileSync(join(appsDir, appFile), 'utf-8'); + const entries = unreachable.map((n) => ` { id: 'nav_${n}', type: 'object', objectName: '${n}' },\n`).join(''); + if (!source.includes(' navigation: [\n')) throw new Error(`${appFile} has no \`navigation: [\` line to add to`); + writeFileSync(join(appsDir, appFile), source.replace(' navigation: [\n', ` navigation: [\n${entries}`)); + } + const withoutView = await read('object-without-view'); + const steps: { args: string[]; run: Run }[] = []; + for (const n of withoutView) { + const args = ['g', 'view', n.startsWith(`${ns}_`) ? n.slice(ns.length + 1) : n]; + steps.push({ args, run: await os(args, dir) }); + } + return { unreachable, withoutView, steps }; +} + beforeAll(async () => { root = mkdtempSync(join(HERE, '..', 'node_modules', '.generate-scaffold-gates-')); // Sequential on purpose: cold starts in a container several agents share. @@ -312,12 +392,16 @@ beforeAll(async () => { steps.push({ args, run: await os(args, dir) }); } } + const answered = await answerAppShell(dir, NS); const gates = {} as Leg['gates']; for (const gate of GATES) { const r = await os([gate, '--json'], dir); gates[gate] = { run: r, findings: findingsOf(gate, r.stdout) }; } - legs[leg] = { dir, steps, ...(wake ? { wake } : {}), gates }; + legs[leg] = { + dir, steps, ...(wake ? { wake } : {}), + shell: { unreachable: answered.unreachable, withoutView: answered.withoutView, steps: answered.steps }, gates, + }; if (leg === BARE) starterListed = navListedObjects(builtStack(dir)); } }, RUN_TIMEOUT_MS); @@ -376,7 +460,10 @@ describe('[#32393] the starter\'s app, which `os g app` and `os g permission` me expect(wake, `leg ${kind} ran no \`os validate\` before granting`).toBeDefined(); expect(wake!.run.code, out(wake!.run)).toBe(0); expect(wake!.findings, `os validate --json printed no JSON:\n${out(wake!.run)}`).not.toBeNull(); - expect([...wake!.findings!].sort()).toEqual( + // [#35143] The object the leg generated is one no entry opens; it is + // answered after the grants, and pinned in the app-shell block below. + const woken = wake!.findings!.filter((f) => !f.startsWith('object-unreachable-from-navigation@')); + expect([...woken].sort()).toEqual( starterListed.map(({ path }) => `nav-object-ungranted@${path}`).sort(), ); }, @@ -404,11 +491,41 @@ describe('[#21325] every generator: fresh starter + `os g ` → zero findi const { run: r, findings } = legs[kind].gates[gate]; expect(r.code, out(r)).toBe(0); expect(findings, `os ${gate} --json printed no JSON:\n${out(r)}`).not.toBeNull(); - expect(findings!.filter((f) => !(f in STARTER_LATENT_FINDINGS))).toEqual([]); + expect(findings!.filter((f) => !(f in STARTER_LATENT_FINDINGS) && !scaffoldAdvisory(kind, f))).toEqual([]); }, ); }); +describe('[#35143] the app shell a scaffold leaves to its author, and the one advisory it carries', () => { + const starterObjects = () => itemsOf(builtStack(legs[BARE].dir).objects).map((o) => String(o.name)); + + it('the bare starter needs no answer: every object it declares is opened from navigation, with a view', () => { + expect(legs[BARE].shell).toMatchObject({ unreachable: [], withoutView: [], steps: [] }); + }); + + it('every `os g view` the answer ran exits 0', () => { + for (const [leg, l] of Object.entries(legs)) { + for (const { args, run: r } of l.shell.steps) expect(r.code, `${leg}: os ${args.join(' ')}\n${out(r)}`).toBe(0); + } + }); + + it('an object a leg generates is reported unreachable, and no object of the starter ever is', () => { + const answered = Object.entries(legs).flatMap(([, l]) => [...l.shell.unreachable, ...l.shell.withoutView]); + expect(answered.length, 'no leg generated an object: the answer step is dead').toBeGreaterThan(0); + for (const name of answered) expect(starterObjects()).not.toContain(name); + expect(legs.object.shell.unreachable).toEqual([target('object').itemName(ITEM, NS)]); + }); + + it.each(Object.keys(SCAFFOLD_ADVISORIES))('`os g %s` carries its own advisory at every gate, and no other leg does', (kind) => { + const { finding } = SCAFFOLD_ADVISORIES[kind]; + for (const gate of GATES) expect(legs[kind].gates[gate].findings, gate).toContain(finding); + for (const [leg, l] of Object.entries(legs)) { + if (leg === kind) continue; + for (const gate of GATES) expect(l.gates[gate].findings ?? [], `${leg} ${gate}`).not.toContain(finding); + } + }); +}); + describe('[#21325] the starter ledger cannot outlive its defect or cover a scaffold', () => { it('[#21370] is at its floor: EMPTY — a starter finding is a template to fix, never a line to add', () => { expect( @@ -469,6 +586,7 @@ describe('[#32153] a fresh `os init` project: the new generator variants pass ev let dir = ''; const steps = new Map(); const gates = {} as Record; + let shell: Awaited>; let refusal: Run; let viewsBeforeRefusal: string[] = []; let viewsAfterRefusal: string[] = []; @@ -479,6 +597,7 @@ describe('[#32153] a fresh `os init` project: the new generator variants pass ev if (init.code !== 0) throw new Error(`os init failed: ${out(init)}`); dir = join(initRoot, INIT_PROJECT); for (const args of VARIANTS) steps.set(args.join(' '), await os([...args], dir)); + shell = await answerAppShell(dir, INIT_NS); for (const gate of GATES) { const r = await os([gate, '--json'], dir); gates[gate] = { run: r, findings: findingsOf(gate, r.stdout) }; @@ -499,11 +618,16 @@ describe('[#32153] a fresh `os init` project: the new generator variants pass ev expect(r.code, out(r)).toBe(0); }); - it.each(GATES)('then `os %s`: exit 0 and no finding at any severity', (gate) => { + it('[#35143] the new object is the one no entry opens; its named view already lists it', () => { + expect(shell.unreachable).toEqual([`${INIT_NS}_ticket`]); + expect(shell.withoutView).toEqual([]); + }); + + it.each(GATES)('then `os %s`: exit 0 and no finding beyond the dashboard scaffold\'s own', (gate) => { const { run: r, findings } = gates[gate]; expect(r.code, out(r)).toBe(0); expect(findings, `os ${gate} --json printed no JSON:\n${out(r)}`).not.toBeNull(); - expect(findings).toEqual([]); + expect(findings).toEqual([SCAFFOLD_ADVISORIES.dashboard.finding]); }); it('the object is written in the starter style, and its barrel line re-exports it by name', () => { diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts index 60490283459..6565f563763 100644 --- a/packages/lint/src/authoring-rules.ts +++ b/packages/lint/src/authoring-rules.ts @@ -1086,11 +1086,7 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ source: 'packages/lint/src/validate-widget-bindings.ts', surfaces: CLI_AND_RUNTIME, runtimeTypes: ['dashboard'], - // [#35143] `dashboard-without-widgets` is an error on the CLI and a warning - // at the runtime door, where Studio's own create paths save a dashboard - // with `widgets: []` before its first widget; `runtimeWriteType` is set by - // the runtime gate alone. - run: (stack, ctx) => validateWidgetBindings(stack, { atPublishDoor: ctx.runtimeWriteType !== undefined }), + run: (stack) => validateWidgetBindings(stack), }, // #16354 — the AUTHORING-TIME leg of the aggregate × field-type contract // (director ruling, decision batch #59, 2026-09-06: "both legs, table in diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index 22a71908d86..ed4e8f753f7 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -1585,9 +1585,9 @@ const DASHBOARD_WITHOUT_WIDGETS_EXPLANATION: RuleExplanation = { 'A dashboard with `widgets: []` parses and publishes, and opens on its header over an empty canvas: the ' + 'renderer draws no empty state for it, so a user reaching it from navigation sees nothing and is told ' + 'nothing.', - 'An error on `os validate`, `os lint` and `os build`, where a shipped package has nothing left to add. A ' + - 'warning at the runtime publish door, because Studio creates a new dashboard with `widgets: []` and ' + - 'fills it afterwards, and the door must not refuse the platform\'s own first step.', + 'A warning at every door (`os validate`, `os lint`, `os build` and the runtime publish door): the shape ' + + 'breaks no request, and the platform\'s own create steps write `widgets: []` and fill it afterwards ' + + '(Studio, the spec\'s dashboard create seed, and `os generate dashboard`).', 'To fix it, add a widget bound to a dataset, or remove the dashboard and any navigation entry that ' + 'opens it.', ], @@ -1612,14 +1612,15 @@ const OBJECT_UNREACHABLE_FROM_NAVIGATION_EXPLANATION: RuleExplanation = { covers: 'when an object is reachable from the app shell', paragraphs: [ 'An object is reachable when some app\'s navigation, or navigation the stack contributes into another ' + - 'package\'s app, names it in a `type: \'object\'` entry. An object nothing names is stored and served, ' + - 'but no user can open its list from the shell.', + 'package\'s app, names it in a `type: \'object\'` entry. The finding says only that no navigation ' + + 'entry opens the object\'s list; it does not say no user can reach a record some other way.', 'A warning, on `os validate`, `os lint` and `os build` only: the verdict reads every app and object of ' + 'the stack, which the runtime door\'s per-write snapshot does not carry. Not judged: a stack with no ' + - 'app and no contributed navigation, an object with a `master_detail` field (it shows as a related list ' + - 'on its parent), and an object whose `enable.apiEnabled` is `false`.', - 'To fix it, add a `type: \'object\'` entry for it to an app\'s navigation, or make it the child of the ' + - 'object it belongs to with a `master_detail` field.', + 'app and no contributed navigation; an object with a `master_detail` field, or one another object ' + + 'names in `relatedLists` (it shows on its parent\'s record page); an object a page names when a ' + + '`type: \'page\'` entry opens that page; and an object whose `enable.apiEnabled` is `false`.', + 'To fix it, add a `type: \'object\'` entry for it to an app\'s navigation, or name it in its parent ' + + 'object\'s `relatedLists`.', ], }; @@ -1627,12 +1628,14 @@ const OBJECT_WITHOUT_VIEW_EXPLANATION: RuleExplanation = { rule: 'object-without-view', covers: 'what an object opened from navigation shows with no view', paragraphs: [ - 'An object a navigation entry opens, with no `list`, no `listViews` entry and no `views` item bound to it, ' + + 'An object a navigation entry opens as a list (an entry with no `recordId`), with no `listViews` entry ' + + 'and no `views` item bound to it, ' + 'opens on an "All records" tab the console builds itself: the name field followed by `highlightFields`, ' + 'or by the first five fields in declared order, with no filter, sort or grouping and no other tab.', 'A warning, on `os validate`, `os lint` and `os build` only, for the reason `object-unreachable-from-' + 'navigation` gives. Judged only for objects navigation opens, the one place that list is shown.', - 'To fix it, declare the list users should see: a `list` on the object, or a `views` entry bound to it.', + 'To fix it, declare the list users should see: a `listViews` entry on the object, or a `views` entry ' + + 'bound to it.', ], }; diff --git a/packages/lint/src/validate-app-shell-reach.test.ts b/packages/lint/src/validate-app-shell-reach.test.ts index 253b60faaae..e6766e9ed2f 100644 --- a/packages/lint/src/validate-app-shell-reach.test.ts +++ b/packages/lint/src/validate-app-shell-reach.test.ts @@ -121,6 +121,20 @@ describe('[#35143] object-unreachable-from-navigation and object-without-view', expect(validateAppNavigationPresent(artifact)).toEqual([]); }); + it('an object another object lists in `relatedLists`, or that a page navigation opens names, is not judged', () => { + const parent = { ...objects[0], relatedLists: ['crm_note.account'] }; + const nav = { objects: [parent, objects[1]], views: [accountView], apps: [app(navTo('crm_account'))] }; + expect(run(nav)).toEqual([]); + const objectForm = { ...objects[0], relatedLists: [{ list: 'crm_note', label: 'Notes' }] }; + expect(run({ ...nav, objects: [objectForm, objects[1]] })).toEqual([]); + const pageEntry = { id: 'p', type: 'page', label: 'Notes', pageName: 'notes_page' }; + const page = { name: 'notes_page', regions: [{ components: [{ type: 'object:list', properties: { objectName: 'crm_note' } }] }] }; + const viaPage = { objects, views: [accountView], pages: [page], apps: [app(navTo('crm_account'), pageEntry)] }; + expect(run(viaPage)).toEqual([]); + // A page no entry opens reaches nothing. + expect(run({ ...viaPage, apps: [app(navTo('crm_account'))] })).toEqual([[OBJECT_UNREACHABLE_FROM_NAVIGATION, 'objects[1]']]); + }); + it('a master-detail child and an API-disabled object are not judged; a stack with no app is not judged', () => { const child = { name: 'crm_note', fields: { account: { type: 'master_detail', reference: 'crm_account' } } }; const hidden = { name: 'crm_log', enable: { apiEnabled: false }, fields: { body: { type: 'text' } } }; @@ -129,7 +143,6 @@ describe('[#35143] object-unreachable-from-navigation and object-without-view', }); it.each([ - ['an object `list`', { objects: [{ ...objects[0], list: { type: 'grid', columns: ['name'] } }] }], ['an object `listViews` entry', { objects: [{ ...objects[0], listViews: { all: { type: 'grid', columns: ['name'] } } }] }], ['a `views` item', { objects: [objects[0]], views: [accountView] }], ['a flattened list overlay', { objects: [objects[0]], views: [{ name: 'a.x', object: 'crm_account', viewKind: 'list', columns: ['name'] }] }], @@ -141,7 +154,17 @@ describe('[#35143] object-unreachable-from-navigation and object-without-view', const findings = validateObjectShellReach({ objects: [objects[0]], apps: [app(navTo('crm_account'))] }); expect(findings.map((f) => [f.rule, f.severity, f.path])).toEqual([[OBJECT_WITHOUT_VIEW, 'warning', 'objects[0]']]); expect(findings[0].message).toContain('All records'); - expect(findings[0].hint).toContain('list:'); + expect(findings[0].hint).toContain('listViews:'); + }); + + it('an entry that opens one record (`recordId`) shows no list, so no view is owed', () => { + const recordEntry = { ...navTo('crm_account'), recordId: '{current_user_id}' }; + expect(run({ objects: [objects[0]], apps: [app(recordEntry)] })).toEqual([]); + }); + + it('the object `list` key is not a list view: `ObjectSchema` declares `listViews`', () => { + const stray = { objects: [{ ...objects[0], list: { type: 'grid', columns: ['name'] } }], apps: [app(navTo('crm_account'))] }; + expect(run(stray)).toEqual([[OBJECT_WITHOUT_VIEW, 'objects[0]']]); }); it('runs on all three commands as an advisory, and never at the runtime door', () => { diff --git a/packages/lint/src/validate-app-shell-reach.ts b/packages/lint/src/validate-app-shell-reach.ts index 831391fd81b..ad29a73c512 100644 --- a/packages/lint/src/validate-app-shell-reach.ts +++ b/packages/lint/src/validate-app-shell-reach.ts @@ -23,20 +23,25 @@ * * An object the stack declares and no navigation entry of any app (nor any * navigation the stack contributes into another package's app) names in a - * `type: 'object'` entry. Its records exist and its API answers, but no user - * can open its list from the shell. Not judged: + * `type: 'object'` entry. The finding claims only what it read: no navigation + * entry opens the object's list. Not judged, because the shell shows the + * object some other way or the object is not meant to be listed: * * - a stack that declares no app and contributes no navigation (a package of * objects other packages present); - * - an object with a `master_detail` field: it is shown as a related list on - * its parent's record page, which is where such a child belongs; + * - an object with a `master_detail` field, or one another object names in + * its `relatedLists` (bare `child` / `child.field`, or the object form's + * `list`): it is shown as a related list on its parent's record page; + * - an object a page names (an `object` / `objectName` value anywhere in a + * page that a `type: 'page'` entry opens): the page presents it; * - an object whose `enable.apiEnabled` is `false`: its list cannot be served, * which `nav-object-unservable` already says of any entry that opens it. * * ## `object-without-view` — an object opened from navigation with no list view * - * An object a navigation entry opens that declares no list view: no `list`, no - * `listViews` entry, and no `views[]` item bound to it. The console then + * An object a navigation entry opens as a list (a `type: 'object'` entry with + * no `recordId`, which opens one record instead) that declares no list view: + * no `listViews` entry and no `views[]` item bound to it. The console then * builds an "All records" tab of its own (`buildViewTabs`' fallback in * objectui): the name field followed by `highlightFields`, or by the first five * fields in declared order, with no filter, sort or grouping and no second tab. @@ -83,17 +88,52 @@ function hasEntry(items: unknown): boolean { }); } -/** Every `objectName` a `type: 'object'` entry names in a navigation tree, at any depth. */ -function collectNavObjects(items: unknown, into: Set): void { +/** What a navigation tree opens, at any depth. */ +interface NavReach { + /** Every `objectName` a `type: 'object'` entry names. */ + objects: Set; + /** The subset an entry opens as a LIST: one with no `recordId`. */ + lists: Set; + /** Every `pageName` a `type: 'page'` entry names. */ + pages: Set; +} + +function collectNav(items: unknown, into: NavReach): void { if (!Array.isArray(items)) return; for (const item of items) { if (!isRec(item)) continue; const objectName = item.type === 'object' ? strName(item.objectName) : undefined; - if (objectName) into.add(objectName); - if (item.type !== 'separator') collectNavObjects(item.children, into); + if (objectName) { + into.objects.add(objectName); + if (item.recordId === undefined) into.lists.add(objectName); + } + const pageName = item.type === 'page' ? strName(item.pageName) : undefined; + if (pageName) into.pages.add(pageName); + if (item.type !== 'separator') collectNav(item.children, into); } } +/** Every string an `object` or `objectName` key holds anywhere under `node`. */ +function collectNamedObjects(node: unknown, into: Set, depth = 0): void { + if (depth > 64) return; + if (Array.isArray(node)) { + for (const v of node) collectNamedObjects(v, into, depth + 1); + return; + } + if (!isRec(node)) return; + for (const [key, v] of Object.entries(node)) { + const named = key === 'object' || key === 'objectName' ? strName(v) : undefined; + if (named) into.add(named); + else collectNamedObjects(v, into, depth + 1); + } +} + +/** The child object a `relatedLists` entry names: `child`, `child.field`, or the object form's `list`. */ +function relatedListChild(entry: unknown): string | undefined { + const spelled = typeof entry === 'string' ? entry : isRec(entry) ? strName(entry.list) : undefined; + return spelled ? strName(spelled.split('.')[0]) : undefined; +} + /** One collection holder: the stack itself, or one `packages[].manifest` body. */ interface Holder { body: AnyRec; @@ -101,23 +141,17 @@ interface Holder { prefix: string; } -/** - * The holders whose apps and objects are JUDGED: the stack itself only. An - * assembled artifact's `packages[]` is judged by the CLI's per-package run - * (`runPerPackageAuthoringRules`), which hands each package to these rules as - * a stack of its own; judging it here too would report each item twice. - */ -function judgedHolders(stack: AnyRec): Holder[] { - return [{ body: stack, prefix: '' }]; -} - /** * The holders whose navigation COUNTS toward reach: the stack and every * package of an assembled artifact, so an entry one package contributes into - * another's app reaches the object wherever the object is judged. + * another's app reaches the object wherever the object is judged. Only the + * stack itself (the first holder) is JUDGED: an assembled artifact's + * `packages[]` is judged by the CLI's per-package run + * (`runPerPackageAuthoringRules`), which hands each package to these rules as + * a stack of its own; judging it here too would report each item twice. */ function reachHolders(stack: AnyRec): Holder[] { - const holders = judgedHolders(stack); + const holders: Holder[] = [{ body: stack, prefix: '' }]; packagesOf(stack).forEach((entry, i) => { if (isRec(entry.manifest)) holders.push({ body: entry.manifest, prefix: `packages[${i}].manifest.` }); }); @@ -167,24 +201,22 @@ export function validateAppNavigationPresent(stack: AnyRec): AppShellReachFindin const findings: AppShellReachFinding[] = []; if (!isRec(stack)) return findings; const contributed = contributedAppNames(reachHolders(stack)); - for (const holder of judgedHolders(stack)) { - for (const { app, path, name } of appsOf(holder)) { - if (hasEntry(app.navigation)) continue; - if (recordsOf(app.areas).some((area) => hasEntry(area.navigation))) continue; - if (contributed.has(name)) continue; - findings.push({ - severity: 'warning', - rule: APP_NAVIGATION_EMPTY, - where: `app "${name}"`, - path: `${path}.navigation`, - message: - `app "${name}" has no navigation entry (none in \`navigation\` or in any \`areas[].navigation\`), so ` + - 'it opens on the "no access" empty state for every member, its author included', - hint: - "Add an entry that opens something, e.g. `navigation: [{ id: 'nav_home', type: 'object', label: '…', " + - "objectName: '' }]`, or remove the app", - }); - } + for (const { app, path, name } of appsOf({ body: stack, prefix: '' })) { + if (hasEntry(app.navigation)) continue; + if (recordsOf(app.areas).some((area) => hasEntry(area.navigation))) continue; + if (contributed.has(name)) continue; + findings.push({ + severity: 'warning', + rule: APP_NAVIGATION_EMPTY, + where: `app "${name}"`, + path: `${path}.navigation`, + message: + `app "${name}" has no navigation entry (none in \`navigation\` or in any \`areas[].navigation\`), so ` + + 'it opens on the "no access" empty state for every member, its author included', + hint: + "Add an entry that opens something, e.g. `navigation: [{ id: 'nav_home', type: 'object', label: '…', " + + "objectName: '' }]`, or remove the app", + }); } return findings; } @@ -198,9 +230,8 @@ function viewBinds(view: AnyRec, object: string): boolean { return isRec(view.listViews) && Object.values(view.listViews).some((lv) => bound(lv) === object); } -/** Whether an object declares a list view of its own. */ +/** Whether an object declares a list view of its own (`ObjectSchema.listViews`). */ function declaresOwnView(obj: AnyRec): boolean { - if (isRec(obj.list)) return true; return isRec(obj.listViews) && Object.values(obj.listViews).some(isRec); } @@ -217,64 +248,78 @@ export function validateObjectShellReach(stack: AnyRec): AppShellReachFinding[] if (!isRec(stack)) return findings; const holders = reachHolders(stack); - const reached = new Set(); + const nav: NavReach = { objects: new Set(), lists: new Set(), pages: new Set() }; let navigates = false; for (const holder of holders) { for (const { app } of appsOf(holder)) { navigates = true; - collectNavObjects(app.navigation, reached); - for (const area of recordsOf(app.areas)) collectNavObjects(area.navigation, reached); + collectNav(app.navigation, nav); + for (const area of recordsOf(app.areas)) collectNav(area.navigation, nav); } for (const contribution of contributionsOf(holder.body)) { navigates = true; - collectNavObjects(contribution.items, reached); + collectNav(contribution.items, nav); } } if (!navigates) return findings; + // Shown some other way: through a page navigation opens, or as a related + // list on a parent's record page. + const shownElsewhere = new Set(); + for (const holder of holders) { + for (const page of recordsOf(holder.body.pages)) { + const name = strName(page.name); + if (name && nav.pages.has(name)) collectNamedObjects(page, shownElsewhere); + } + for (const obj of recordsOf(holder.body.objects)) { + for (const entry of Array.isArray(obj.relatedLists) ? obj.relatedLists : []) { + const child = relatedListChild(entry); + if (child) shownElsewhere.add(child); + } + } + } + const views = holders.flatMap((holder) => recordsOf(holder.body.views)); - for (const holder of judgedHolders(stack)) { - const objects = holder.body.objects; - if (!Array.isArray(objects)) continue; - objects.forEach((obj, i) => { - if (!isRec(obj)) return; - const name = strName(obj.name); - if (!name) return; - const path = `${holder.prefix}objects[${i}]`; - if (!reached.has(name)) { - if (hasMasterDetailField(obj)) return; - if (isRec(obj.enable) && obj.enable.apiEnabled === false) return; - findings.push({ - severity: 'warning', - rule: OBJECT_UNREACHABLE_FROM_NAVIGATION, - where: `object "${name}"`, - path, - message: - `no app's navigation opens object "${name}" (no \`type: 'object'\` entry names it), so its records ` + - 'are stored and served but no user can reach its list from the app shell', - hint: - `Add \`{ id: 'nav_${name}', type: 'object', label: '…', objectName: '${name}' }\` to an app's ` + - '`navigation`, or make it a child of the object it belongs to (a `master_detail` field) so it shows ' + - "as a related list on the parent's record page", - }); - return; - } - if (declaresOwnView(obj) || views.some((view) => viewBinds(view, name))) return; + const objects = Array.isArray(stack.objects) ? stack.objects : []; + objects.forEach((obj, i) => { + if (!isRec(obj)) return; + const name = strName(obj.name); + if (!name) return; + const path = `objects[${i}]`; + if (!nav.objects.has(name)) { + if (shownElsewhere.has(name) || hasMasterDetailField(obj)) return; + if (isRec(obj.enable) && obj.enable.apiEnabled === false) return; findings.push({ severity: 'warning', - rule: OBJECT_WITHOUT_VIEW, + rule: OBJECT_UNREACHABLE_FROM_NAVIGATION, where: `object "${name}"`, path, message: - `object "${name}" is opened from navigation but declares no list view, so the console builds an ` + - '"All records" tab of its own: the name field and `highlightFields` (or the first five fields), ' + - 'with no filter, sort or grouping and no other tab', + `no navigation entry opens object "${name}" (no \`type: 'object'\` entry names it, no page an entry ` + + "opens names it, and no object lists it in `relatedLists`), so the app shell offers no way to its list", hint: - `Declare the list users should see: \`list: { type: 'grid', columns: [...] }\` on "${name}", or a ` + - `\`views\` entry bound to it (\`defineView({ object: '${name}', list: { ... } })\`)`, + `Add \`{ id: 'nav_${name}', type: 'object', label: '…', objectName: '${name}' }\` to an app's ` + + "`navigation`, or name it in its parent object's `relatedLists` so it shows on the parent's record page", }); + return; + } + if (!nav.lists.has(name)) return; + if (declaresOwnView(obj) || views.some((view) => viewBinds(view, name))) return; + findings.push({ + severity: 'warning', + rule: OBJECT_WITHOUT_VIEW, + where: `object "${name}"`, + path, + message: + `object "${name}" is opened from navigation but declares no list view, so the console builds an ` + + '"All records" tab of its own: the name field and `highlightFields` (or the first five fields), ' + + 'with no filter, sort or grouping and no other tab', + hint: + `Declare the list users should see: \`listViews: { all: { type: 'grid', columns: [...] } }\` on ` + + `"${name}", or a ` + + `\`views\` entry bound to it (\`defineView({ object: '${name}', list: { ... } })\`)`, }); - } + }); return findings; } diff --git a/packages/lint/src/validate-widget-bindings.test.ts b/packages/lint/src/validate-widget-bindings.test.ts index 134fecce0af..d90ba930cf8 100644 --- a/packages/lint/src/validate-widget-bindings.test.ts +++ b/packages/lint/src/validate-widget-bindings.test.ts @@ -2341,8 +2341,8 @@ describe('[#22161] one-line fix — the rule ids whose `fix:` line this file sho }); // [#35143] A dashboard with no widgets publishes and opens on its header over -// an empty canvas. An error on the CLI; a warning at the runtime door, where -// Studio creates a dashboard with `widgets: []` and fills it afterwards. +// an empty canvas. A warning at every door: Studio, the spec's create seed and +// `os generate dashboard` all write `widgets: []` and fill it afterwards. describe('[#35143] a dashboard with no widgets', () => { const EMPTY = { name: 'ops_board', label: 'Ops', widgets: [] }; const datasets = [{ name: 'task_stats', object: 'task', measures: [{ name: 'n', aggregate: 'count' }] }]; @@ -2351,12 +2351,12 @@ describe('[#35143] a dashboard with no widgets', () => { ...EMPTY, widgets: [{ id: 'w1', type: 'metric', dataset: 'task_stats', values: ['n'], layout: { x: 0, y: 0, w: 3, h: 2 } }], }; - const emptyFindings = (stack: Record, atPublishDoor?: boolean) => - validateWidgetBindingsUnrecorded(stack, { atPublishDoor }).filter((f) => f.rule === DASHBOARD_WITHOUT_WIDGETS); + const emptyFindings = (stack: Record) => + validateWidgetBindingsUnrecorded(stack).filter((f) => f.rule === DASHBOARD_WITHOUT_WIDGETS); - it('is an error at `widgets` on the CLI, naming the fix', () => { + it('is a warning at `widgets`, naming the fix', () => { const findings = emptyFindings({ objects, datasets, dashboards: [EMPTY] }); - expect(findings.map((f) => [f.severity, f.path])).toEqual([['error', 'dashboards[0].widgets']]); + expect(findings.map((f) => [f.severity, f.path])).toEqual([['warning', 'dashboards[0].widgets']]); expect(findings[0].hint).toContain('Add a widget'); }); @@ -2365,10 +2365,13 @@ describe('[#35143] a dashboard with no widgets', () => { expect(emptyFindings({ objects, datasets, dashboards: [{ name: 'x', label: 'X' }] })).toEqual([]); }); - for (const command of ['validate', 'build'] as const) { - it(`fails \`${command}\``, () => { - const { errors } = splitBySeverity(runAuthoringRules(command, { normalized: { objects, datasets, dashboards: [EMPTY] } })); - expect(errors.map((f) => f.rule)).toContain(DASHBOARD_WITHOUT_WIDGETS); + for (const command of ['validate', 'build', 'lint'] as const) { + it(`is an advisory on \`${command}\`, never an error`, () => { + const { errors, advisories } = splitBySeverity( + runAuthoringRules(command, { normalized: { objects, datasets, dashboards: [EMPTY] } }), + ); + expect(advisories.map((f) => f.rule)).toContain(DASHBOARD_WITHOUT_WIDGETS); + expect(errors.map((f) => f.rule)).not.toContain(DASHBOARD_WITHOUT_WIDGETS); }); } @@ -2381,8 +2384,8 @@ describe('[#35143] a dashboard with no widgets', () => { expect(filled.advisories.map((f) => f.rule)).not.toContain(DASHBOARD_WITHOUT_WIDGETS); }); - it('`os explain` carries the split severity', () => { + it('`os explain` says why it is advisory', () => { const text = explainRule(DASHBOARD_WITHOUT_WIDGETS)!.paragraphs.join('\n'); - for (const fact of ['`widgets: []`', 'runtime publish door', 'Studio']) expect(text, fact).toContain(fact); + for (const fact of ['`widgets: []`', 'Studio', 'os generate dashboard']) expect(text, fact).toContain(fact); }); }); diff --git a/packages/lint/src/validate-widget-bindings.ts b/packages/lint/src/validate-widget-bindings.ts index 60866cd1566..02ac29728fc 100644 --- a/packages/lint/src/validate-widget-bindings.ts +++ b/packages/lint/src/validate-widget-bindings.ts @@ -453,12 +453,12 @@ export const WIDGET_LEGACY_ANALYTICS_UNRENDERABLE = 'widget-legacy-analytics-unr /** * [#35143] A dashboard that declares no widget: it publishes and opens on its * header over an empty canvas (`DashboardRenderer.tsx` in objectui draws no - * empty state for it). An `error` on `os validate` / `lint` / `build`, where a - * shipped package has nothing left to add; a `warning` at the runtime publish - * door, because Studio's own create paths save a new dashboard with - * `widgets: []` and fill it afterwards (`newItemBody` in `designModeMenuCreate.ts`, - * the `dashboard` resource's `createDefaults` in `anchors.ts`), and refusing - * that save would refuse the platform's own first step. + * empty state for it). A `warning` at every door: the shape breaks no request, + * and the platform's own create steps write it and fill it afterwards (the + * spec's dashboard create seed, Studio's `newItemBody` in + * `designModeMenuCreate.ts` and the `dashboard` resource's `createDefaults` in + * `anchors.ts`, and `os generate dashboard`), so a tree still being built + * meets it as a step, not a defect. */ export const DASHBOARD_WITHOUT_WIDGETS = 'dashboard-without-widgets'; export const DASHBOARD_FILTER_FIELD_UNKNOWN = 'dashboard-filter-field-unknown'; @@ -505,16 +505,6 @@ const LEGACY_ANALYTICS_KEYS = [ export type WidgetBindingSeverity = 'error' | 'warning'; -/** How {@link validateWidgetBindings} is being called. */ -export interface WidgetBindingOptions { - /** - * [#35143] Set by the runtime publish gate's entry: the stack is the - * snapshot of one write at the save/publish door, where - * {@link DASHBOARD_WITHOUT_WIDGETS} is advisory. - */ - atPublishDoor?: boolean; -} - export interface WidgetBindingFinding { /** `error` = unresolvable binding (broken page); `warning` = advisory. */ severity: WidgetBindingSeverity; @@ -1121,10 +1111,7 @@ function measureColumn(measure: AnyRec): string | undefined { * should fail validate/build; `warning` findings are advisory and must * never fail the build on their own. */ -export function validateWidgetBindings( - stack: AnyRec, - options?: WidgetBindingOptions, -): WidgetBindingFinding[] { +export function validateWidgetBindings(stack: AnyRec): WidgetBindingFinding[] { const findings: WidgetBindingFinding[] = []; const resolution = indexArtifactDatasetResolution(stack); @@ -1194,12 +1181,11 @@ export function validateWidgetBindings( const dash = dashboards[i]; const dashName = typeof dash.name === 'string' ? dash.name : `(dashboard ${i})`; const widgets = Array.isArray(dash.widgets) ? (dash.widgets as AnyRec[]) : []; - // [#35143] No widget at all — see DASHBOARD_WITHOUT_WIDGETS for the split - // severity. Judged on an array only: a missing or malformed `widgets` is + // [#35143] No widget at all — see DASHBOARD_WITHOUT_WIDGETS. Judged on an array only: a missing or malformed `widgets` is // the schema's refusal, not this rule's. if (Array.isArray(dash.widgets) && dash.widgets.length === 0) { findings.push({ - severity: options?.atPublishDoor ? 'warning' : 'error', + severity: 'warning', rule: DASHBOARD_WITHOUT_WIDGETS, where: `dashboard "${dashName}"`, path: `dashboards[${i}].widgets`, diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts index 874ab25e854..93b756c40d5 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts @@ -3,31 +3,29 @@ import type { SemanticMigration } from '../../types.js'; // The upgrade-guide entry of the Views, dashboards and app shell family of the -// second batch of author-time rules (#35143): a list view filter or a dashboard -// the schema still accepts but that shows nothing, refused at publish and in -// `os validate` / `build`, and four advisories on the app shell. Notice only: -// no key is removed and no D2 conversion exists, because each fix is a choice -// only the author can make (which stored field to filter on, which widget to -// add). +// second batch of author-time rules (#35143): a list view filter the schema +// still accepts but the engine refuses, refused at publish and in +// `os validate` / `build`, and five advisories on dashboards, boards and the +// app shell. Notice only: no key is removed and no D2 conversion exists, +// because the fix is a choice only the author can make (which stored field to +// filter on). export const entry: SemanticMigration = { id: 'publish-refuses-views-and-dashboards-that-save-and-do-not-work', surface: - 'Two author-time errors, run by `os validate` / `lint` / `compile` / `build`: a list view filter, or a ' + 'One author-time error, run by `os validate` / `lint` / `compile` / `build`: a list view filter, or a ' + '`userFilters.tabs[]` preset, keyed on a `formula` field (`list-view-filter-field-virtual`, also refused by ' - + 'the runtime publish gate on a `view` or `object` write); and a dashboard with `widgets: []` ' - + '(`dashboard-without-widgets`, a warning at the runtime publish gate, where Studio creates a dashboard empty). ' - + 'Four warnings: a `kanban` board grouped by a field with no fixed set of lanes ' + + 'the runtime publish gate on a `view` or `object` write). ' + + 'Five warnings: a dashboard with `widgets: []` (`dashboard-without-widgets`), a `kanban` board grouped by a ' + + 'field with no fixed set of lanes ' + '(`list-view-kanban-group-field-uncategorical`), an app with no navigation entry (`app-navigation-empty`), an ' + 'object no app\'s navigation opens (`object-unreachable-from-navigation`) and an object navigation opens with ' + 'no list view (`object-without-view`)', replacement: - 'Filter on the stored fields the formula reads, or on a stored field written when its sources change; add a ' - + 'widget bound to a dataset, or remove the dashboard', + 'Filter on the stored fields the formula reads, or on a stored field written when its sources change', reason: - 'Each parses and publishes, then shows nothing: the engine refuses a query filtered on a field computed on read ' - + '(400 INVALID_FIELD), so the view opens on that error every time; a dashboard with no widgets opens on its ' - + 'header over an empty canvas. Stored metadata is not rewritten or refused at boot. The next publish of a view ' + 'The filter parses and publishes, then shows nothing: the engine refuses a query filtered on a field computed ' + + 'on read (400 INVALID_FIELD), so the view opens on that error every time. Stored metadata is not rewritten or refused at boot. The next publish of a view ' + 'or object carrying such a filter is refused with the fix named; the warnings never refuse.', acceptanceCriteria: - 'os validate reports neither error; a publish of every view and object the package carries succeeds.', + 'os validate reports no list-view-filter-field-virtual error; a publish of every view and object the package carries succeeds.', }; From 17f62e759dfab5f598fc08fbfd56473b88f06d36 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 03:14:48 +0000 Subject: [PATCH 6/8] test(showcase): list the app-shell advisories the reference app keeps, each with its reason Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- .../test/author-time-advisories.test.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/app-showcase/test/author-time-advisories.test.ts b/examples/app-showcase/test/author-time-advisories.test.ts index 23def79961e..e2953fd4ea9 100644 --- a/examples/app-showcase/test/author-time-advisories.test.ts +++ b/examples/app-showcase/test/author-time-advisories.test.ts @@ -76,6 +76,17 @@ const NESTED_FAN_OUT = + 'pinned by test/nested-fan-out-region-indices.test.ts. Wrapping the notify step in a try_catch puts a region ' + 'between the parallel branch and the step whose (iteration, branch) tags the clause reads.'; +const DERIVED_LIST = + 'Opened from the app\'s navigation on the console\'s own derived list ("All records": the name field and ' + + 'highlightFields, or the first five fields). The showcase demonstrates designed lists on projects, tasks, ' + + 'contacts and the field zoo; this object keeps the derived one, and declaring a list here would change what ' + + 'the browser checklist items on it observe. #35143 made the advisory; designing the list is a separate change.'; + +const OFF_NAVIGATION = + 'Deliberately not in the app\'s navigation: the object exists to demonstrate a server-side contract (sharing ' + + 'model, share links, a public form, federation, or served semantic roles) that its tests drive over REST, ' + + 'and the app shell is not what it shows. The rule claims only that no navigation entry opens its list.'; + export const ALLOWED_ADVISORIES: readonly Allowed[] = [ // ── Approval slates (info) ─────────────────────────────────────────────── { rule: 'approval-approvers-may-resolve-empty', where: 'flow "showcase_expense_signoff" · node "dual_signoff"', reason: POSITION_SLATE }, @@ -147,6 +158,20 @@ export const ALLOWED_ADVISORIES: readonly Allowed[] = [ reason: 'A junction row: every surface that lists it names it by its two masters (team and project), and it ' + 'has no text field for nameField to point at. Records fall back to the stable Record #ID floor.', }, + + // ── App shell (#35143): the derived list, and objects kept off navigation (warning) ── + ...['showcase_account', 'showcase_cascade', 'showcase_category', 'showcase_expense_report', 'showcase_invoice', + 'showcase_preference', 'showcase_product', 'showcase_team'].map((name): Allowed => ({ + rule: 'object-without-view', where: `object "${name}"`, reason: DERIVED_LIST, + })), + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_announcement"', reason: OFF_NAVIGATION + ' Public-read OWD sibling of showcase_private_note.' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_private_note"', reason: OFF_NAVIGATION + ' Owner-private OWD; the Capability Map page links to it by URL, which the rule does not read.' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_client_brief"', reason: OFF_NAVIGATION + ' The share-link (publicSharing) object, opened by its capability token.' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_inquiry"', reason: OFF_NAVIGATION + ' The public form\'s inbox; the Contact Form page submits into it.' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_semantic_zoo"', reason: OFF_NAVIGATION + ' A served-pipeline fixture of the semantic-roles dogfood test.' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_semantic_zoo_legacy"', reason: OFF_NAVIGATION + ' The legacy-spelling twin of showcase_semantic_zoo, same dogfood test.' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_ext_customer"', reason: OFF_NAVIGATION + ' Federated read-only from the external SQLite datasource (ADR-0015).' }, + { rule: 'object-unreachable-from-navigation', where: 'object "showcase_ext_order"', reason: OFF_NAVIGATION + ' Federated read-only from the external SQLite datasource (ADR-0015).' }, ]; /** From d95f7a4ea791518956f42a4e1fa4b658a418a2af Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 03:43:24 +0000 Subject: [PATCH 7/8] test(cli): the in-process scaffold pin answers the app shell and carries the dashboard scaffold's advisory Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- .../test/generate-scaffold-validates.test.ts | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/cli/test/generate-scaffold-validates.test.ts b/packages/cli/test/generate-scaffold-validates.test.ts index 317b1f70f02..de7b5dd93c7 100644 --- a/packages/cli/test/generate-scaffold-validates.test.ts +++ b/packages/cli/test/generate-scaffold-validates.test.ts @@ -117,6 +117,18 @@ import { BUNDLE_REQUIRE_EXTERNALS } from '../src/utils/config.js'; */ const KNOWN_UNVALIDATED_SCAFFOLDS: Record = {}; +/** + * [#35143] The advisory a generator's own output raises, carried rather than + * answered, with why — the same ledger `generate-scaffold-gates.e2e.test.ts` + * keeps. `os g dashboard` writes `widgets: []` under a comment naming the + * widget shape; which dataset and measures a dashboard shows is the author's + * to say, so the scaffold cannot fill it, and `dashboard-without-widgets` is + * that comment as a finding. Pinned to fire for this generator, nowhere else. + */ +const SCAFFOLD_ADVISORIES: Record = { dashboard: 'dashboard-without-widgets' }; +const isScaffoldAdvisory = (type: string, line: string) => + SCAFFOLD_ADVISORIES[type] !== undefined && line.includes(` warning ${SCAFFOLD_ADVISORIES[type]} at `); + /** The namespace the host stack declares, so every object name is judged against a prefix. */ const NS = 'scaffold'; /** The name `os g ` is invoked with for the item under test. */ @@ -226,6 +238,22 @@ async function projectWith(type: string): Promise<{ stack: Record { + const bound = target('object').itemName(PREREQUISITE_STEM.object, NS); + const lines = findings(stackOf(project)).filter((l) => l.includes(' warning object-without-view at ')); + if (lines.length === 0) return false; + for (const l of lines) expect(l, 'only the prerequisite object can lack a view').toContain(`object "${bound}"`); + await generateInto(project, 'view', PREREQUISITE_STEM.object); + return true; +} + /** Everything the three commands would report for `stack`, every severity, one line each. */ function findings(stack: Record): string[] { const out: string[] = []; @@ -288,8 +316,16 @@ describe('[#14087 / #21325] every `os generate` scaffold passes `os validate`, ` const known = GENERATOR_SCAFFOLD_TARGETS.filter((t) => t.type in KNOWN_UNVALIDATED_SCAFFOLDS); it.each(clean)('`os g $type` adds no finding at any severity, beside what it binds', async (t) => { - const { stack } = await projectWith(t.type); - expect(findings(stack), `the gates report the ${t.type} scaffold`).toEqual([]); + const project: Project = { items: [] }; + await generateInto(project, t.type, ITEM); + const answered = await answerAppShell(project); + // Only `os g app` opens an object from navigation; it opens the one it binds. + expect(answered, `\`os g ${t.type}\` left an object opened with no list view`).toBe(t.type === 'app'); + const all = findings(stackOf(project)); + expect(all.filter((l) => !isScaffoldAdvisory(t.type, l)), `the gates report the ${t.type} scaffold`).toEqual([]); + if (SCAFFOLD_ADVISORIES[t.type]) { + expect(all.map((l) => l.split(':')[0]), 'carried at every gate').toEqual(['validate', 'build', 'lint']); + } }); it.each(known)( @@ -426,6 +462,7 @@ describe('[#32153] the generators write the starter\'s style, and each new varia const app = await generateInto(project, 'app', 'main'); // The printed line, pasted where the author is told to paste it. (app.navigation as unknown[]).push(await loadScaffold('app', `export default ${entry!.replace(/,$/, '')};\n`)); - expect(findings(stackOf(project))).toEqual([]); + expect(await answerAppShell(project)).toBe(true); + expect(findings(stackOf(project)).filter((l) => !isScaffoldAdvisory('dashboard', l))).toEqual([]); }); }); From 2399eab8c8d4def0a51a605fe5d08fa920893bee Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 04:31:20 +0000 Subject: [PATCH 8/8] test(cli): three integration fixtures open their objects from navigation, each on a declared list Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK --- .../lint-per-package-authoring-parity.test.ts | 5 +++++ packages/cli/test/package-union-readers.test.ts | 16 ++++++++++++---- .../test/stack-conversion-record-door.test.ts | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/cli/test/lint-per-package-authoring-parity.test.ts b/packages/cli/test/lint-per-package-authoring-parity.test.ts index 089807470ff..16ab6bf0719 100644 --- a/packages/cli/test/lint-per-package-authoring-parity.test.ts +++ b/packages/cli/test/lint-per-package-authoring-parity.test.ts @@ -144,6 +144,11 @@ const ordersManifest = { id: 'com.example.ppflip.orders', name: 'ppflip orders', namespace: 'pp', version: '1.0.0', type: 'module', engines: { protocol: '^19' }, dependencies: { 'com.example.ppflip.core': '^1.0.0' }, + // [#35143] Orders puts its object into core's app (ADR-0029 D7), so the + // union run reaches \`pp_order\` and raises nothing for it. + navigationContributions: [ + { app: 'pp_crm', items: [{ id: 'nav_orders', type: 'object', objectName: 'pp_order', label: 'Orders' }] }, + ], }; const ordersObjects = [{ name: 'pp_order', label: 'Order', pluralLabel: 'Orders', sharingModel: 'private', diff --git a/packages/cli/test/package-union-readers.test.ts b/packages/cli/test/package-union-readers.test.ts index c270cb30ee5..ebc54c7e1ad 100644 --- a/packages/cli/test/package-union-readers.test.ts +++ b/packages/cli/test/package-union-readers.test.ts @@ -88,12 +88,20 @@ const engines = { protocol: '^19' }; const svcManifest = { id: '${SVC_ID}', name: 'Union Service', namespace: 'unr', version: '1.0.0', type: 'module', engines }; const appManifest = { id: '${APP_ID}', name: 'Union App', namespace: 'unr', version: '1.0.0', type: 'app', engines }; const ticket = { name: 'unr_ticket', label: 'Ticket', pluralLabel: 'Tickets', sharingModel: 'private', - fields: { title: { name: 'title', type: 'text', label: 'Title', required: true } } }; + fields: { title: { name: 'title', type: 'text', label: 'Title', required: true } }, + listViews: { all: { type: 'grid', columns: ['title'] } } }; const note = { name: 'unr_note', label: 'Note', pluralLabel: 'Notes', sharingModel: 'private', - fields: { name: { name: 'name', type: 'text', label: 'Name', required: true } } }; -const app = { name: 'unr_app', label: 'Union', navigation: [{ id: 'nav_tickets', type: 'object', objectName: 'unr_ticket', label: 'Tickets' }] }; + fields: { name: { name: 'name', type: 'text', label: 'Name', required: true } }, + listViews: { all: { type: 'grid', columns: ['name'] } } }; +// [#35143] The app opens both objects, each on a list it declares, so the +// app-shell advisories stay silent and the fixture stays clean. The note is +// the service package's, so its entry says the object comes from elsewhere. +const app = { name: 'unr_app', label: 'Union', navigation: [ + { id: 'nav_tickets', type: 'object', objectName: 'unr_ticket', label: 'Tickets' }, + { id: 'nav_notes', type: 'object', objectName: 'unr_note', requiresObject: 'unr_note', label: 'Notes' }, +] }; const ticketZh = { 'zh-CN': { objects: { unr_ticket: { label: '工单', pluralLabel: '工单', fields: { title: { label: '标题' } } } }, - apps: { unr_app: { label: '联合', navigation: { nav_tickets: { label: '工单' } } } }, + apps: { unr_app: { label: '联合', navigation: { nav_tickets: { label: '工单' }, nav_notes: { label: '笔记' } } } }, packages: { '${APP_ID}': { name: '联合应用' } } } }; const noteZh = { 'zh-CN': { objects: { unr_note: { label: '笔记', fields: { name: { label: '名称' } } } }, packages: { '${SVC_ID}': { name: '联合服务' } } } }; diff --git a/packages/cli/test/stack-conversion-record-door.test.ts b/packages/cli/test/stack-conversion-record-door.test.ts index 9f494a1f7d3..70702caadb5 100644 --- a/packages/cli/test/stack-conversion-record-door.test.ts +++ b/packages/cli/test/stack-conversion-record-door.test.ts @@ -168,8 +168,8 @@ const flow = (ns: string, nodeType: NodeType) => `{ const stackBody = (ns: string, nodeType: NodeType | null, requires?: string) => `{ manifest: ${manifest(ns)}, - objects: [{ name: '${ns}_thing', label: 'Thing', sharingModel: 'private', fields: { title: { type: 'text', label: 'Title' } } }], - apps: [{ name: '${ns}_app', label: 'App' }],${nodeType ? `\n flows: [${flow(ns, nodeType)}],` : ''}${requires ? `\n requires: ['${requires}'],` : ''} + objects: [{ name: '${ns}_thing', label: 'Thing', sharingModel: 'private', fields: { title: { type: 'text', label: 'Title' } }, listViews: { all: { type: 'grid', columns: ['title'] } } }], + apps: [{ name: '${ns}_app', label: 'App', navigation: [{ id: 'nav_thing', type: 'object', objectName: '${ns}_thing', label: 'Things' }] }],${nodeType ? `\n flows: [${flow(ns, nodeType)}],` : ''}${requires ? `\n requires: ['${requires}'],` : ''} }`; const IMPORT = `import { composeStacks, defineStack } from '@objectstack/spec';\n\n`;