Skip to content

Commit f76bbfb

Browse files
committed
fix(lint): field-group-shadowed judges the six highlights the record page hoists
The record page draws the first six highlightFields in its header strip and leaves them out of the Details body; the lint judged four, so a group emptied by the fifth or sixth highlight passed. The count is now one constant, RECORD_HIGHLIGHTS_MAX in @objectstack/spec/ui, read by the lint and by the record page synthesizer in @object-ui/plugin-detail. Claude-Session: https://claude.ai/code/session_01L6bhgUZrkMKgGrXXe8zPGq Co-authored-by: Claude <noreply@anthropic.com>
1 parent 50d4ae8 commit f76bbfb

9 files changed

Lines changed: 133 additions & 21 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/lint': minor
3+
'@objectstack/spec': minor
4+
'@object-ui/plugin-detail': minor
5+
---
6+
7+
fix(lint): `field-group-shadowed` judges the six highlights the record page draws, from one shared constant
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: narrowed
11+
12+
The default record page draws the first six of an object's `highlightFields` (after the title field leaves the list) in its header strip and leaves those fields out of the Details body. The `field-group-shadowed` warning judged only the first four, so a field group whose only member sat fifth or sixth in `highlightFields` was empty on the record page and passed `os lint --strict`. It now judges the same six, and its hint says "first 6 highlightFields".
13+
14+
What was accepted before and is warned now: an object whose field group is emptied by its fifth or sixth highlight. Fix it as the hint says: keep a member of that group out of the first six highlights, or drop the group. A list the old count warned is still warned: six hoisted fields include the first four, so no list that passed only under six is refused.
15+
16+
New export: `@objectstack/spec/ui` adds `RECORD_HIGHLIGHTS_MAX` (6), the count both the lint and `@object-ui/plugin-detail`'s record page synthesizer read. `@object-ui/plugin-detail` now takes its own `RECORD_HIGHLIGHTS_MAX` from there; the value and the page are unchanged.
17+
18+
<!-- adr-0087: registered field-group-shadowed-six-highlights -->

‎packages/lint/src/validate-semantic-roles.test.ts‎

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('validateSemanticRoles (ADR-0085)', () => {
130130
expect(findings[0].message).toContain('amount');
131131
});
132132

133-
it('rule d counts the title field as hidden-from-body and respects the 4-entry strip cap', () => {
133+
it('rule d counts the title field as hidden-from-body and respects the 6-entry strip cap', () => {
134134
// A group holding only the record title never renders in the body even
135135
// though the title is filtered OUT of the strip.
136136
const titleOnly = validateSemanticRoles(stack([{
@@ -141,15 +141,15 @@ describe('validateSemanticRoles (ADR-0085)', () => {
141141
}]));
142142
expect(titleOnly.map((f) => f.rule)).toEqual([FIELD_GROUP_SHADOWED]);
143143

144-
// Entry #5 is beyond the strip (first 4 after the title filter), so a
144+
// Entry #7 is beyond the strip (first 6 after the title filter), so a
145145
// group containing it still renders → clean.
146146
const beyondCap = validateSemanticRoles(stack([{
147147
name: 'wide',
148-
highlightFields: ['name', 'a', 'b', 'c', 'd', 'e'],
148+
highlightFields: ['name', 'a', 'b', 'c', 'd', 'e', 'f', 'g'],
149149
fieldGroups: [{ key: 'tail', label: 'Tail' }],
150150
fields: {
151-
name: {}, a: {}, b: {}, c: {}, d: {},
152-
e: { type: 'text', group: 'tail' },
151+
name: {}, a: {}, b: {}, c: {}, d: {}, e: {}, f: {},
152+
g: { type: 'text', group: 'tail' },
153153
},
154154
}]));
155155
expect(beyondCap).toEqual([]);
@@ -169,6 +169,43 @@ describe('validateSemanticRoles (ADR-0085)', () => {
169169
expect(hiddenMember.map((f) => f.rule)).toEqual([FIELD_GROUP_SHADOWED]);
170170
});
171171

172+
// The record page hoists RECORD_HIGHLIGHTS_MAX (6) highlights and its body
173+
// leaves them out. The rule used to cut at 4, so a group whose only member
174+
// sat 5th or 6th was emptied on the page and passed the lint.
175+
it('rule d judges the six highlights the record page hoists, not four', () => {
176+
for (const position of [5, 6]) {
177+
const strip = ['a', 'b', 'c', 'd', 'e', 'f'];
178+
const owner = strip[position - 1];
179+
const findings = validateSemanticRoles(stack([{
180+
name: 'lead',
181+
highlightFields: strip,
182+
fieldGroups: [{ key: 'basics', label: 'Basics' }, { key: 'assignment', label: 'Assignment' }],
183+
fields: {
184+
name: { type: 'text', group: 'basics' }, notes: { type: 'textarea', group: 'basics' },
185+
...Object.fromEntries(strip.map((n) => [n, { type: 'text', ...(n === owner ? { group: 'assignment' } : {}) }])),
186+
},
187+
}]));
188+
expect(findings, `position ${position}`).toHaveLength(1);
189+
expect(findings[0]).toMatchObject({ severity: 'warning', rule: FIELD_GROUP_SHADOWED, path: 'objects[0].fieldGroups' });
190+
expect(findings[0]?.message).toContain('"assignment"');
191+
expect(findings[0]?.hint).toContain('first 6 highlightFields');
192+
}
193+
194+
// Control: four highlights out of a six-slot strip, every group keeping
195+
// a member the body draws → clean.
196+
const fourOfSix = validateSemanticRoles(stack([{
197+
name: 'lead',
198+
highlightFields: ['a', 'b', 'c', 'd'],
199+
fieldGroups: [{ key: 'basics', label: 'Basics' }, { key: 'assignment', label: 'Assignment' }],
200+
fields: {
201+
name: { type: 'text', group: 'basics' }, notes: { type: 'textarea', group: 'basics' },
202+
a: { type: 'text', group: 'basics' }, b: { type: 'text' }, c: { type: 'text' },
203+
d: { type: 'text', group: 'assignment' }, owner_id: { type: 'text', group: 'assignment' },
204+
},
205+
}]));
206+
expect(fourOfSix).toEqual([]);
207+
});
208+
172209
// #6326 — rule (d)'s title resolution used to read
173210
// `[nameField, primaryField, displayNameField]`. `primaryField` is declared
174211
// NOWHERE in `packages/spec`: measured on 17.0.0-rc.5,
@@ -183,26 +220,26 @@ describe('validateSemanticRoles (ADR-0085)', () => {
183220
// make the fixture schema-valid: that deletes the coverage.
184221
//
185222
// The pair below is the discriminating one. Title resolution matters here
186-
// because the title is filtered OUT of the 4-entry strip, so whether
187-
// `ref_no` counts as the title decides whether entry #5 (`d`) lands inside
188-
// the strip. Read as the title → strip is [a,b,c,d], group "tail" (only
189-
// member `d`) is fully hidden → SHADOWED. Not read → strip is
190-
// [ref_no,a,b,c], `d` still renders → clean. No field here is one of the
223+
// because the title is filtered OUT of the 6-entry strip, so whether
224+
// `ref_no` counts as the title decides whether entry #7 (`f`) lands inside
225+
// the strip. Read as the title → strip is [a,b,c,d,e,f], group "tail"
226+
// (only member `f`) is fully hidden → SHADOWED. Not read → strip is
227+
// [ref_no,a,b,c,d,e], `f` still renders → clean. No field here is one of the
191228
// conventional fallbacks (name/full_name/title/subject/display_name), and
192229
// none is an injected system column, so nothing else can supply a title.
193230
it('ignores primaryField in title resolution; nameField still resolves (#6326)', () => {
194231
const withPhantomKey = validateSemanticRoles(stack([{
195232
name: 'ledger_entry',
196233
primaryField: 'ref_no',
197-
highlightFields: ['ref_no', 'a', 'b', 'c', 'd'],
234+
highlightFields: ['ref_no', 'a', 'b', 'c', 'd', 'e', 'f'],
198235
fieldGroups: [{ key: 'tail', label: 'Tail' }],
199236
fields: {
200237
ref_no: { type: 'text' }, a: { type: 'text' }, b: { type: 'text' },
201-
c: { type: 'text' }, d: { type: 'text', group: 'tail' },
238+
c: { type: 'text' }, d: { type: 'text' }, e: { type: 'text' }, f: { type: 'text', group: 'tail' },
202239
},
203240
}]));
204241
// Goes red the moment the `primaryField` entry returns to the chain:
205-
// `ref_no` would become the title, `d` would fall inside the strip, and
242+
// `ref_no` would become the title, `f` would fall inside the strip, and
206243
// one FIELD_GROUP_SHADOWED finding would appear.
207244
expect(withPhantomKey).toEqual([]);
208245

@@ -212,11 +249,11 @@ describe('validateSemanticRoles (ADR-0085)', () => {
212249
const withNameField = validateSemanticRoles(stack([{
213250
name: 'ledger_entry',
214251
nameField: 'ref_no',
215-
highlightFields: ['ref_no', 'a', 'b', 'c', 'd'],
252+
highlightFields: ['ref_no', 'a', 'b', 'c', 'd', 'e', 'f'],
216253
fieldGroups: [{ key: 'tail', label: 'Tail' }],
217254
fields: {
218255
ref_no: { type: 'text' }, a: { type: 'text' }, b: { type: 'text' },
219-
c: { type: 'text' }, d: { type: 'text', group: 'tail' },
256+
c: { type: 'text' }, d: { type: 'text' }, e: { type: 'text' }, f: { type: 'text', group: 'tail' },
220257
},
221258
}]));
222259
// Indexed rather than `.map((f) => f.rule)` on purpose: this file's

‎packages/lint/src/validate-semantic-roles.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* are different questions, and only one of them moved.
2929
*/
3030

31+
import { RECORD_HIGHLIGHTS_MAX } from '@objectstack/spec/ui';
3132
import { injectedColumnsFor, unprovisionedInjectedColumnsFor } from './system-fields.js';
3233
import { recordsOf } from './object-graph.js';
3334

@@ -215,8 +216,12 @@ export function validateSemanticRoles(stack: AnyRec): SemanticRoleFinding[] {
215216
}
216217

217218
// ── (d) declared group fully shadowed by the detail highlight strip ──
218-
// Detail pages render the first 4 highlightFields as the top strip and
219-
// HIDE those fields from the details body; the record's title field is
219+
// Detail pages render the first RECORD_HIGHLIGHTS_MAX highlightFields
220+
// (after the title leaves the list) as the top strip and HIDE those
221+
// fields from the details body. The count is the spec constant the record
222+
// page synthesizer cuts with, so the verdict and the screen cannot drift
223+
// apart; a literal here once judged 4 while the page drew 6, so a group
224+
// emptied by the 5th or 6th highlight passed. The record's title field is
220225
// the page H1 and never renders in the body either. A group whose every
221226
// visible member is covered by strip ∪ title therefore renders on FORMS
222227
// but silently never on detail pages — legal, but almost never what the
@@ -239,7 +244,7 @@ export function validateSemanticRoles(stack: AnyRec): SemanticRoleFinding[] {
239244
const titleField = declaredTitle
240245
?? ['name', 'full_name', 'title', 'subject', 'display_name'].find((c) => fieldNames.has(c));
241246
const stripSet = new Set(
242-
declaredStrings.filter((h) => h !== titleField).slice(0, 4),
247+
declaredStrings.filter((h) => h !== titleField).slice(0, RECORD_HIGHLIGHTS_MAX),
243248
);
244249
const hiddenFromBody = new Set(stripSet);
245250
if (titleField) hiddenFromBody.add(titleField);
@@ -263,7 +268,7 @@ export function validateSemanticRoles(stack: AnyRec): SemanticRoleFinding[] {
263268
hint:
264269
`Keep at least one non-highlighted field in "${key}", or remove the ` +
265270
`group if the strip already covers it. (Detail pages show the first ` +
266-
`4 highlightFields as the top strip and hide them from the body.)`,
271+
`${RECORD_HIGHLIGHTS_MAX} highlightFields as the top strip and hide them from the body.)`,
267272
});
268273
}
269274
}

‎packages/spec/api-surface/ui.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@
389389
"REACT_RETIRED_OVERLAY_PROPS (const)",
390390
"RECORD_CONTEXT_BLOCK_TAGS (const)",
391391
"RECORD_CONTEXT_TYPE_PREFIX (const)",
392+
"RECORD_HIGHLIGHTS_MAX (const)",
392393
"RESERVED_COMPONENT_TYPE_NAMESPACES (const)",
393394
"RETIRED_PAGE_COMPONENT_TYPES (const)",
394395
"ReactBlockDef (interface)",

‎packages/spec/export-origins/ui.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@
381381
"REACT_RETIRED_OVERLAY_PROPS": "src/ui/react-blocks.ts#REACT_RETIRED_OVERLAY_PROPS (const)",
382382
"RECORD_CONTEXT_BLOCK_TAGS": "src/ui/react-blocks.ts#RECORD_CONTEXT_BLOCK_TAGS (const)",
383383
"RECORD_CONTEXT_TYPE_PREFIX": "src/ui/react-blocks.ts#RECORD_CONTEXT_TYPE_PREFIX (const)",
384+
"RECORD_HIGHLIGHTS_MAX": "src/ui/component.zod.ts#RECORD_HIGHLIGHTS_MAX (const)",
384385
"RESERVED_COMPONENT_TYPE_NAMESPACES": "src/ui/component-type-vocabulary.ts#RESERVED_COMPONENT_TYPE_NAMESPACES (const)",
385386
"RETIRED_PAGE_COMPONENT_TYPES": "src/ui/page.zod.ts#RETIRED_PAGE_COMPONENT_TYPES (const)",
386387
"ReactBlockDef": "src/ui/react-blocks.ts#ReactBlockDef (interface)",

‎packages/spec/liveness/object.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"highlightFields": {
4646
"status": "live",
4747
"proof": "packages/qa/dogfood/test/semantic-roles.dogfood.test.ts#semantic-roles-served",
48-
"note": "ADR-0085 semantic role (renamed from compactLayout): objectui default list/grid columns (ObjectGrid/ObjectView/InterfaceListPage), child-record previews (first entry), record:details auto layout, detail highlight strip (first 4)."
48+
"note": "ADR-0085 semantic role (renamed from compactLayout): objectui default list/grid columns (ObjectGrid/ObjectView/InterfaceListPage), child-record previews (first entry), record:details auto layout, detail highlight strip (first RECORD_HIGHLIGHTS_MAX = 6, after the title)."
4949
},
5050
"relatedLists": {
5151
"status": "live",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import type { SemanticMigration } from '../../types.js';
4+
5+
// The upgrade-guide entry of the `field-group-shadowed` warning moving from the
6+
// first four highlightFields to the six the default record page draws
7+
// (RECORD_HIGHLIGHTS_MAX, `@objectstack/spec/ui`). Notice only: no key is
8+
// removed and no D2 conversion exists, because which field leaves the strip, or
9+
// whether the group goes, is a choice only the author can make.
10+
export const entry: SemanticMigration = {
11+
id: 'field-group-shadowed-six-highlights',
12+
surface:
13+
'The `field-group-shadowed` warning of `os validate` / `lint` / `compile` / `build`: a field group of an object '
14+
+ 'whose every visible member is the record title or one of the first six `highlightFields` (after the title '
15+
+ 'leaves the list). It judged the first four before',
16+
replacement:
17+
'Keep at least one member of the group out of the first six `highlightFields`, or remove the group if the record '
18+
+ 'header strip already shows its fields',
19+
reason:
20+
'The default record page draws the first six highlights in its header strip and leaves those fields out of the '
21+
+ 'Details body, so a group whose only members sit there is empty on the record page while it still shows on '
22+
+ 'forms. The warning judged four of the six, so a group emptied by the fifth or sixth highlight passed. A group '
23+
+ 'it warned before is still warned. Stored items are not rewritten or refused at publish; like any warning, it '
24+
+ 'makes `os validate --strict` exit 1.',
25+
acceptanceCriteria:
26+
'os validate reports no `field-group-shadowed` warning, and each declared field group shows at least one field '
27+
+ 'in the Details body of the default record page.',
28+
};

‎packages/spec/src/ui/component.zod.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,23 @@ export const RecordRelatedListProps = strictObject({
18621862
aria: AriaPropsSchema.optional().describe('ARIA accessibility attributes'),
18631863
});
18641864

1865+
/**
1866+
* How many of an object's declared `highlightFields` (ADR-0085), after the
1867+
* record's title field leaves the list, the DEFAULT record page draws in its
1868+
* header strip. The Details body leaves those fields out, so an entry past
1869+
* this count is drawn in the body instead.
1870+
*
1871+
* The one source both readers ask: the record page synthesizer in
1872+
* `@object-ui/plugin-detail` cuts the strip with it, and the
1873+
* `field-group-shadowed` lint in `@objectstack/lint` judges with it which
1874+
* field groups the strip empties on the record page. A second literal on
1875+
* either side is how the lint came to judge four while the page drew six.
1876+
*
1877+
* Not the bound of an authored `record:highlights` block's `fields`
1878+
* ({@link RecordHighlightsProps}): an authored page writes its own strip.
1879+
*/
1880+
export const RECORD_HIGHLIGHTS_MAX = 6;
1881+
18651882
/**
18661883
* ⚠️ The object arm is CLOSED, and closing a union arm is a different act from
18671884
* closing a plain shape — worth reading before the next arm is touched.

‎ui/packages/plugin-detail/src/synth/buildDefaultPageSchema.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525

2626
import { deriveFieldGroupLayout } from '@objectstack/spec/data';
27+
import { RECORD_HIGHLIGHTS_MAX } from '@objectstack/spec/ui';
2728
import type { SelectOptionKind, ServiceObject } from '@objectstack/spec/data';
2829
import { detectStatusField } from '@object-ui/types';
2930
import { resolveNameField } from '@object-ui/core';
@@ -446,8 +447,12 @@ export function resolveTitleField(def: ObjectDefLike | undefined): string | null
446447
* How many highlights the record header shows (objectstack#27055, the v3
447448
* header: 「要点 6 项等宽」 — the same six Studio's highlight editor offers).
448449
* A declared `highlightFields` list longer than this is cut here.
450+
*
451+
* Declared once in `@objectstack/spec/ui` and re-exported here: the
452+
* `field-group-shadowed` lint judges which field groups this strip empties
453+
* with the same constant, so its verdict matches the page.
449454
*/
450-
export const RECORD_HIGHLIGHTS_MAX = 6;
455+
export { RECORD_HIGHLIGHTS_MAX };
451456

452457
/**
453458
* The record's highlight strip: the object's DECLARED `highlightFields`

0 commit comments

Comments
 (0)