Skip to content

Commit 60eae03

Browse files
committed
refactor(plugin-view): read the three declared object-view keys without a cast
`data`, `navigation` and `searchableFields` are declared members of `ObjectViewSchema`, so the `renderListView` relay reads them as `schema.K`. The 27 objectui#5097 host-composition reads keep their cast. The fence pin now derives the cast set (27) and the uncast declared set separately; the 7779 census pins follow the new source text. Claude-Session: https://claude.ai/code/session_01JQwxbaGCrvY8peSVMF3rQw Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8d79bbd commit 60eae03

3 files changed

Lines changed: 50 additions & 26 deletions

File tree

‎ui/packages/plugin-view/src/ObjectView.tsx‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -864,11 +864,11 @@ type FormMode = 'create' | 'edit' | 'view';
864864
* ## The verdict
865865
*
866866
* The delegation branch in `renderContent` below reads 30 distinct keys off
867-
* the object-view node through `(schema as any).K` and forwards them to the
868-
* host's list renderer. Three of them — `data`, `navigation`,
869-
* `searchableFields`, listed in
867+
* the object-view node and forwards them to the host's list renderer. Three
868+
* of them — `data`, `navigation`, `searchableFields`, listed in
870869
* {@link OBJECT_VIEW_DECLARED_FORWARDED_KEYS} — are declared members of
871-
* `ObjectViewSchema`. The other 27, listed here, are not, and stay that way:
870+
* `ObjectViewSchema` and are read without a cast. The other 27, listed here,
871+
* are read through `(schema as any).K`, are not declared, and stay that way:
872872
* they are HOST-COMPOSITION surface, not authored surface. This constant is
873873
* their single home; the branch is fenced by `#region` markers so the pin in
874874
* `src/__tests__/objectViewHostSurface.test.tsx` fails BY NAME when a read is
@@ -986,9 +986,10 @@ export const OBJECT_VIEW_HOST_COMPOSITION_KEYS = [
986986
] as const;
987987

988988
/**
989-
* The other three keys the same branch reads through `(schema as any)`: these
990-
* ARE declared members of `ObjectViewSchema` (`data` via `BaseSchema`), so
991-
* they are authored surface and are NOT part of the objectui#5097 exemption.
989+
* The other three keys the same branch reads off the node: these ARE declared
990+
* members of `ObjectViewSchema` (`data` via `BaseSchema`), so they are
991+
* authored surface, are read as `schema.K` with no cast, and are NOT part of
992+
* the objectui#5097 exemption.
992993
* They are listed so the pin can assert the split, not just the exempt half —
993994
* a read that moves from this list into the one above is a key losing its
994995
* declaration, and must fail loudly.
@@ -2954,9 +2955,11 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
29542955
// If a custom renderListView is provided, use it
29552956
// #region object-view HOST-COMPOSITION SURFACE (objectui#5097)
29562957
//
2957-
// 30 of the values assembled below are read off the object-view node with
2958-
// `(schema as any).K`. Three are declared members of `ObjectViewSchema`;
2959-
// the other 27 are NOT, deliberately: the maintainer ruling of 2026-08-18
2958+
// 30 of the values assembled below are read off the object-view node. Three
2959+
// are declared members of `ObjectViewSchema`
2960+
// (`OBJECT_VIEW_DECLARED_FORWARDED_KEYS`) and are read as `schema.K`, with
2961+
// no cast; the other 27 are read with `(schema as any).K` because they are
2962+
// NOT declared, deliberately: the maintainer ruling of 2026-08-18
29602963
// on objectui#5097 (verbatim 「同意」) ruled them HOST-COMPOSITION surface,
29612964
// not authored surface, because this branch is entered only when a HOST
29622965
// passes `renderListView` and the registered renderer never does.
@@ -3106,16 +3109,16 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
31063109
// never reaches the renderer.
31073110
// objectui#8980 / objectui#7928's open half: the cast on the
31083111
// named-view config is GONE — `data` is a declared `NamedListView`
3109-
// member now, so the read and the declaration are one fact. The
3110-
// `activeView` and node rungs keep their casts: the host `views` entry
3111-
// is an untyped host shape and `data` on the node is one of the 27
3112-
// objectui#5097 host-composition keys.
3113-
data: currentNamedViewConfig?.data ?? (activeView as any)?.data ?? (schema as any).data,
3112+
// member now, so the read and the declaration are one fact. The node
3113+
// rung is uncast for the same reason: `data` is declared on the node
3114+
// (via `BaseSchema`). The `activeView` rung keeps its cast: the host
3115+
// `views` entry is an untyped host shape.
3116+
data: currentNamedViewConfig?.data ?? (activeView as any)?.data ?? schema.data,
31143117
// Propagate new spec properties (P0/P1/P2)
3115-
navigation: currentNamedViewConfig?.navigation ?? activeView?.navigation ?? (schema as any).navigation,
3118+
navigation: currentNamedViewConfig?.navigation ?? activeView?.navigation ?? schema.navigation,
31163119
selection: currentNamedViewConfig?.selection ?? activeView?.selection ?? (schema as any).selection,
31173120
pagination: currentNamedViewConfig?.pagination ?? activeView?.pagination ?? (schema as any).pagination,
3118-
searchableFields: currentNamedViewConfig?.searchableFields ?? activeView?.searchableFields ?? (schema as any).searchableFields,
3121+
searchableFields: currentNamedViewConfig?.searchableFields ?? activeView?.searchableFields ?? schema.searchableFields,
31193122
resizable: currentNamedViewConfig?.resizable ?? activeView?.resizable ?? (schema as any).resizable,
31203123
hiddenFields: currentNamedViewConfig?.hiddenFields ?? activeView?.hiddenFields ?? (schema as any).hiddenFields,
31213124
// objectui#8980 — TWO SLOTS THAT HAD NO RUNG ON THIS BRANCH AT ALL.

‎ui/packages/plugin-view/src/__tests__/objectViewHostSurface.test.tsx‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* `ObjectViewSchema`; 27 are not. objectui#13118 dropped one of the four,
3030
* `filterableFields`, with the spec's retirement of the key (objectstack#24640,
3131
* ruling C), so the branch reads 30 today: three declared, the 27 unchanged.
32+
* objectstack#25918 dropped the cast from the three declared reads, so only
33+
* the 27 are still read through `(schema as any).K`.
3234
*
3335
* The maintainer ruled on 2026-08-18 (verbatim 「同意」) that the 27 are HOST
3436
* surface, exempted with reasons — not authored surface — on a MEASURED
@@ -129,6 +131,18 @@ const castReadsIn = (slice: string): string[] =>
129131
),
130132
].sort();
131133

134+
/**
135+
* Every UNCAST read of a key off `schema` in a slice of CODE, distinct, sorted.
136+
* The lookbehind keeps `objectSchema.K` and `x.schema.K` out; the cast form
137+
* never matches, because `schema` is followed by ` as any)` there, not `.`.
138+
*/
139+
const uncastReadsIn = (slice: string): string[] =>
140+
[
141+
...new Set(
142+
[...stripComments(slice).matchAll(/(?<![\w$.])schema\.([A-Za-z_$][\w$]*)/g)].map((m) => m[1]),
143+
),
144+
].sort();
145+
132146
const regionSlice = (): string => {
133147
const start = SOURCE.indexOf(REGION_OPEN);
134148
const end = SOURCE.indexOf(REGION_CLOSE);
@@ -153,8 +167,14 @@ describe('the forwarded key set equals the documented exemption (objectui#5097)'
153167
const exempt: string[] = [...OBJECT_VIEW_HOST_COMPOSITION_KEYS].sort();
154168
const declared: string[] = [...OBJECT_VIEW_DECLARED_FORWARDED_KEYS].sort();
155169

156-
it('the fence reads exactly the 27 exempt keys plus the 3 declared ones', () => {
157-
expect(castReadsIn(regionSlice())).toEqual([...exempt, ...declared].sort());
170+
it('the fence reads exactly the 27 exempt keys through the cast, and the 3 declared ones without it', () => {
171+
// The three declared members are read as `schema.K` since objectstack#25918:
172+
// a cast on a key the type already declares hides nothing and is retired.
173+
// ⛔ That is the ONLY kind of cast this card removed; the 27 stay cast,
174+
// because they are undeclared by ruling.
175+
expect(castReadsIn(regionSlice())).toEqual(exempt);
176+
const uncast = uncastReadsIn(regionSlice());
177+
for (const k of declared) expect(uncast, `\`${k}\` is no longer read off the node uncast`).toContain(k);
158178
});
159179

160180
it('subtracting the declared members leaves exactly the exempt list — by name', () => {
@@ -342,7 +362,7 @@ describe('the fence reads the named view first for every protocol member it rela
342362
expect(cast, `\`${k}\` is now read off the node through a cast`).not.toContain(k);
343363
expect(namedViewReadsIn(regionSlice())).toContain(k);
344364
}
345-
expect(cast).toHaveLength(OBJECT_VIEW_HOST_COMPOSITION_KEYS.length + OBJECT_VIEW_DECLARED_FORWARDED_KEYS.length);
365+
expect(cast).toHaveLength(OBJECT_VIEW_HOST_COMPOSITION_KEYS.length);
346366
});
347367
});
348368

‎ui/packages/types/src/__tests__/object-view-unmirrored-keys-7779.test.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const READ_TEXT: Record<ReadMirrored, ReadonlyArray<readonly [file: string, text
200200
// objectui#10885: the node's `navigation` is still read, now as the fallback
201201
// behind the active named view's.
202202
navigation: [[READER, 'const navigationConfig: ViewNavigationConfig | undefined = currentNamedViewConfig?.navigation ?? schema.navigation;']],
203-
searchableFields: [[READER, 'searchableFields: currentNamedViewConfig?.searchableFields ?? activeView?.searchableFields ?? (schema as any).searchableFields,']],
203+
searchableFields: [[READER, 'searchableFields: currentNamedViewConfig?.searchableFields ?? activeView?.searchableFields ?? schema.searchableFields,']],
204204
allowCreateView: [
205205
[READER, 'allowCreateView: schema.allowCreateView,'],
206206
[SWITCHER, 'const createViewButton = schema.allowCreateView ? ('],
@@ -1095,7 +1095,7 @@ describe('objectui#7779 — the renderer reads the eight mirrored keys, which is
10951095
expect(namedViewReads()).not.toContain(SPEC_RETIRED_UNREAD);
10961096
expect(src).not.toContain('activeView?.filterableFields');
10971097
// Control on the same file and the same spelling: its sibling's rung stands.
1098-
expect(src).toContain('searchableFields: currentNamedViewConfig?.searchableFields ?? activeView?.searchableFields ?? (schema as any).searchableFields,');
1098+
expect(src).toContain('searchableFields: currentNamedViewConfig?.searchableFields ?? activeView?.searchableFields ?? schema.searchableFields,');
10991099
// …and `NamedListView` carries the tombstone, while the node's two faces keep
11001100
// the spec's slot by reference, which carries the spec's own tombstone in at
11011101
// the pin bump that takes the retirement.
@@ -1656,10 +1656,11 @@ describe('objectui#7924 — the per-member liveness census on `NamedListView`, r
16561656
expect(declared.has('data'), '`data` is a declared member since objectui#8980; the census arithmetic subtracts the whole read set').toBe(true);
16571657
expect(reads.reads).toContain('data');
16581658
// …and it is reached through the DECLARED path: the cast on the named-view
1659-
// config is gone. The two neighbouring casts are untouched and stay — the
1660-
// host `views` entry is an untyped host shape, and `data` on the node is one
1661-
// of the 27 objectui#5097 host-composition keys.
1662-
expect(readRepo(READER)).toContain('data: currentNamedViewConfig?.data ?? (activeView as any)?.data ?? (schema as any).data,');
1659+
// config is gone, and so is the one on the node (objectstack#25918) — `data`
1660+
// is declared there too, via `BaseSchema`, and is not one of the 27
1661+
// objectui#5097 host-composition keys. The `activeView` cast stays: the
1662+
// host `views` entry is an untyped host shape.
1663+
expect(readRepo(READER)).toContain('data: currentNamedViewConfig?.data ?? (activeView as any)?.data ?? schema.data,');
16631664
expect(readRepo(READER)).not.toContain('(currentNamedViewConfig as any)?.data');
16641665
});
16651666

0 commit comments

Comments
 (0)