From 2223708d1e1a237b62426bb1ea8cfac351b5240d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 18 Sep 2026 03:10:42 +0000 Subject: [PATCH 1/3] test(lint): derive the list-view position-coverage criterion from the rule The test table's docblock claimed two directions and the assertion under it carried one. `expect(cases.length).toBeGreaterThanOrEqual(51)` counts the rows of the test table, which a position added to the rule's own POSITIONS table never moves, so "a position added to the rule without a row here leaves the count assertion below short" reported nothing at all. That is the direction #18565 came in through. Replace the floor with set equality against a set derived from the rule's own POSITIONS and COLUMN_ENTRY_POSITIONS tables, exposed as a same-package `listViewWalkedPositions()` seam that reaches no published entry (measured: every dist artifact byte-identical to the build that predates it). Both directions now hold, and the offender is named either way. Claude-Session: https://claude.ai/code/session_01JbZnqu8bt6YqfJsr9vaFb3 Co-authored-by: Claude --- .../src/validate-list-view-field-refs.test.ts | 106 +++++++++++++----- .../lint/src/validate-list-view-field-refs.ts | 49 ++++++++ 2 files changed, 130 insertions(+), 25 deletions(-) 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 2ca43110368..809e89837db 100644 --- a/packages/lint/src/validate-list-view-field-refs.test.ts +++ b/packages/lint/src/validate-list-view-field-refs.test.ts @@ -16,6 +16,7 @@ import { validateListViewFieldRefs, LIST_VIEW_FIELD_UNKNOWN, LIST_VIEW_FIELD_DOTTED, + listViewWalkedPositions, type ListViewFieldRefFinding, } from './validate-list-view-field-refs.js'; import { SORT_FIELD_UNKNOWN } from './validate-sortable-fields.js'; @@ -172,25 +173,32 @@ describe('#14107 — the clean surface reports nothing', () => { * The card's own measured table. Each of these five passed `os validate` * (`valid: true, warnings: []`) and `os build` (exit 0, `✓ Build complete`) on * `@objectstack/cli` 17.2.0 — the reason this card exists. + * + * [#18836] At module scope because it is the other half of the coverage the + * completeness assertion below judges: three positions (`grouping.fields`, + * `kanban.groupByField`, `gantt.startDateField`) are asserted HERE and nowhere + * else, so a criterion that read only the sibling table would have to carry a + * hand-written exemption for them — the kind of constant that rots into the + * very lie this card is about. */ -describe('#14107 — the card\'s five measured positions', () => { - const cases: Array<[string, AnyRec, string]> = [ - ['columns[].field', { columns: [{ field: 'B2_no_such_field' }] }, 'views[0].list.columns[0].field'], - [ - 'filter[].field', - { filter: [{ field: 'A8_no_such_field', operator: 'equals', value: 'x' }] }, - 'views[0].list.filter[0].field', - ], - [ - 'grouping.fields[].field', - { grouping: { fields: [{ field: 'A7_no_such_field' }] } }, - 'views[0].list.grouping.fields[0].field', - ], - ['kanban.groupByField', { kanban: { groupByField: 'A9_no_such_field' } }, 'views[0].list.kanban.groupByField'], - ['gantt.startDateField', { gantt: { startDateField: 'B1_no_such_field' } }, 'views[0].list.gantt.startDateField'], - ]; +const MEASURED_CASES: Array<[string, AnyRec, string]> = [ + ['columns[].field', { columns: [{ field: 'B2_no_such_field' }] }, 'views[0].list.columns[0].field'], + [ + 'filter[].field', + { filter: [{ field: 'A8_no_such_field', operator: 'equals', value: 'x' }] }, + 'views[0].list.filter[0].field', + ], + [ + 'grouping.fields[].field', + { grouping: { fields: [{ field: 'A7_no_such_field' }] } }, + 'views[0].list.grouping.fields[0].field', + ], + ['kanban.groupByField', { kanban: { groupByField: 'A9_no_such_field' } }, 'views[0].list.kanban.groupByField'], + ['gantt.startDateField', { gantt: { startDateField: 'B1_no_such_field' } }, 'views[0].list.gantt.startDateField'], +]; - for (const [label, patch, path] of cases) { +describe('#14107 — the card\'s five measured positions', () => { + for (const [label, patch, path] of MEASURED_CASES) { it(`${label} is an error, at a path an author can look up`, () => { const findings = validateListViewFieldRefs(stackWith(mutate(patch))); expect(idsOf(findings)).toEqual([path]); @@ -202,11 +210,33 @@ describe('#14107 — the card\'s five measured positions', () => { } }); +/** + * [#18836] The `POSITIONS` position a case's asserted finding path names, or + * `undefined` when the path belongs to one of the rule's hard-coded filter + * walks (`filter`, `tabs[].filter`, `userFilters.tabs[].filter`), which no + * table declares and which therefore cannot drift out of one. + * + * Two arms, because an `entries` position reports at two different paths: at + * the entry itself when the author wrote a bare field name + * (`gantt.tooltipFields[0]`) and at its `field` key when they wrote a record + * (`gantt.tooltipFields[0].field`). The whole path is tried FIRST, so a + * position whose own key is `field` (`rowColor.field`, and both + * `columns[].summary.field` / `columns[].prefix.field`) matches itself instead + * of being truncated to its block. + */ +function positionAsserted(path: string, walked: ReadonlySet): string | undefined { + const at = path.replace(/^views\[\d+\]\.list\./, '').replace(/\[\d+\]/g, ''); + if (walked.has(at)) return at; + const entry = at.replace(/\.field$/, ''); + return walked.has(entry) ? entry : undefined; +} + /** * Every remaining position, with the severity tier it earns. The table is the * readable half of the rule's own POSITIONS table: a position dropped from the - * rule fails here, and a position added to the rule without a row here leaves - * the count assertion below short. + * rule fails here, and a position added to the rule without a row in either + * table fails the completeness assertion below — which derives the set of + * positions from the rule's own tables instead of counting this one's rows. */ describe('#14107 — every other walked position', () => { const BAD = 'nope_field'; @@ -305,14 +335,40 @@ describe('#14107 — every other walked position', () => { }); } - // A floor, so a position quietly dropped from the rule's table cannot pass - // by simply never being asserted. + // [#18836] The completeness criterion, DERIVED from the rule's own tables. + // + // It replaces a `toBeGreaterThanOrEqual` floor over `cases.length`. That + // floor counted the rows of THIS table, which a position added to the rule + // never moves — so the second direction the docblock above claimed, "a + // position added to the rule without a row here", reported nothing at all. + // That is the direction #18565 came in through: `kanban.titleField` was + // declared by the schema from #16894 and walked by no position row, and this + // file stayed green. + // + // What it asserts, exactly: every position the rule walks is asserted by a + // row in one of this file's two tables. A position added to the rule with no + // row in either is MISSING from the covered set, and the diff names it. + // + // ⛔ It does NOT carry the opposite direction, and saying so is the point + // of this card. `positionAsserted` answers only with positions the rule + // CURRENTLY walks, so a row here for a position the rule has dropped + // contributes to neither side and this assertion stays green. That direction + // belongs to the per-case assertions above — the dropped position stops + // producing a finding and its own `it` fails — which is the first half of + // the docblock above, and both halves were measured on this branch. // - // [#18835] Raised by the four rows this card adds — `calendar.allDayField` - // and the three objectui-lifted `gantt` bindings. The number moves by what - // was added and nothing else; the floor's own semantics are untouched. + // It does take over the floor's own job: a row deleted from either table + // takes its position off the covered set, so the deletion is red. One seam + // it does not cover — the two positions asserted twice on purpose (`columns` + // and `gantt.tooltipFields`, once as a bare name and once as a `{ field }` + // record) keep their position covered when one of the pair is deleted. it('covers every position the rule walks', () => { - expect(cases.length).toBeGreaterThanOrEqual(51); + const walked = listViewWalkedPositions(); + const walkedSet = new Set(walked); + const covered = [...MEASURED_CASES.map(([, , path]) => path), ...cases.map(([, path]) => path)] + .map((path) => positionAsserted(path, walkedSet)) + .filter((position): position is string => position !== undefined); + expect([...new Set(covered)].sort()).toEqual([...walked].sort()); }); }); diff --git a/packages/lint/src/validate-list-view-field-refs.ts b/packages/lint/src/validate-list-view-field-refs.ts index 0b7dd96e446..fb18bf7f6b0 100644 --- a/packages/lint/src/validate-list-view-field-refs.ts +++ b/packages/lint/src/validate-list-view-field-refs.ts @@ -482,6 +482,55 @@ const COLUMN_ENTRY_POSITIONS: Array<{ block: string; key: string; severity: Sev { block: 'prefix', key: 'field', severity: 'warning' }, ]; +/** + * [#18836] Every field-naming position the two declarative tables above make + * this rule walk, as `block.key` — a bare key for the list view's own top + * level, and `columns..` for a position nested inside a `columns[]` + * entry. + * + * DERIVED, never hand-written: `validate-list-view-field-refs.test.ts` asserts + * that its own case tables cover exactly this set, so a position added to + * {@link POSITIONS} with no row over there fails that assertion on the commit + * that adds it. The floor it replaced counted the test table's own rows, which + * a position added HERE never moves — the direction #18565 came in through. + * + * Deliberately NOT re-exported from the package barrel, and deliberately a + * FUNCTION rather than a frozen const. Both halves were measured on this + * branch, `pnpm --filter @objectstack/lint build`, grepping `dist/` with + * `validateListViewFieldRefs` as the bright control: + * + * - Barrel: `src/index.ts` re-exports this module by NAME (no `export *`), so + * an export added here reaches no published entry — 0 occurrences in the + * `export {}` clause of `dist/index.js`, in the `__export` map of + * `dist/index.cjs`, and in all four `.d.ts`/`.d.cts` files, against 1, 1 and + * 2 for the control. + * - Const vs function: as `const X = Object.freeze([...])` esbuild kept the + * initializer as dead weight — 1 occurrence in each of `dist/index.js`, + * `dist/runtime.js` and both `.cjs` siblings, and those four files' bytes + * moved. As the function below it is tree-shaken: 0 occurrences in all + * eight published files, and every one of the nine `dist/` artifacts is + * byte-identical to the build that predates this export. + * + * It names positions only — no severity, no shape — so reading it can never + * stand in for reading the tables. + * + * The three filter walks further down (`listView.filter`, `tabs[].filter`, + * `userFilters.tabs[].filter`) are deliberately absent: they are hard-coded + * seams, not table rows, so nothing about them can drift out of a table. + */ +export function listViewWalkedPositions(): string[] { + return [ + ...Object.entries(POSITIONS).flatMap(([block, spec]) => + [ + ...Object.keys(spec.scalars ?? {}), + ...Object.keys(spec.lists ?? {}), + ...Object.keys(spec.entries ?? {}), + ].map((key) => (block === '' ? key : `${block}.${key}`)), + ), + ...COLUMN_ENTRY_POSITIONS.map(({ block, key }) => `columns.${block}.${key}`), + ]; +} + /** Filter positions on a list view, as `[key path from the view, where suffix]`. */ const SILENT_EMPTY = 'Nothing resolves the name at render time: the view renders successfully with a blank, ' + From 270d9f4b351e2d75858876e959c7af6ea13adae2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 18 Sep 2026 03:15:16 +0000 Subject: [PATCH 2/3] chore(changeset): declare the lint test-criterion change Claude-Session: https://claude.ai/code/session_01JbZnqu8bt6YqfJsr9vaFb3 Co-authored-by: Claude --- .changeset/issue-18836-list-view-position-coverage.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/issue-18836-list-view-position-coverage.md diff --git a/.changeset/issue-18836-list-view-position-coverage.md b/.changeset/issue-18836-list-view-position-coverage.md new file mode 100644 index 00000000000..9ddc71ee045 --- /dev/null +++ b/.changeset/issue-18836-list-view-position-coverage.md @@ -0,0 +1,7 @@ +--- +'@objectstack/lint': minor +--- + +Internal hardening of `validate-list-view-field-refs`' own test suite: the criterion for "every field-naming position the rule walks is asserted" is now derived from the rule's own `POSITIONS` / `COLUMN_ENTRY_POSITIONS` tables instead of a hand-maintained row count, so a position added to the rule with no matching test row fails on the commit that adds it. + +No published entry, type or runtime behaviour changes: the derived seam is not re-exported from the package barrel, and `@objectstack/lint`'s built `dist/` is byte-identical to the build that predates it (all nine artifacts, sha256). From 9897eaae2913a6e7e6581b84de95a82eb07369df Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 18 Sep 2026 04:02:01 +0000 Subject: [PATCH 3/3] test(lint): assert the rule's hard-coded filter walks, and drop the changeset Contract review measured the new criterion losing coverage the row-counting floor had: deleting the two filter-walk rows was red at base (the count fell below 51) and silent at head, because those three walks are open code rather than table rows and nothing derives them. The inline comment nevertheless claimed "a row deleted from either table takes its position off the covered set, so the deletion is red" -- a comment claiming protection it lacks, which is the defect this card is about, delivered by the card's own fix. Declare the three walks as an explicit list and assert it exactly, so a deleted filter row is red and an undeclared fourth walk is red. Restate the residue in the comment per kind of row, including the one seam left open and disclosed: the two positions asserted twice on purpose. Drop the changeset. The review measured 0 changed bytes in every code and type artifact, so a minor would move about 70 lockstep packages for nothing; skip-changeset is the grade. Claude-Session: https://claude.ai/code/session_01JbZnqu8bt6YqfJsr9vaFb3 Co-authored-by: Claude --- ...issue-18836-list-view-position-coverage.md | 7 -- .../src/validate-list-view-field-refs.test.ts | 105 +++++++++++++++--- .../lint/src/validate-list-view-field-refs.ts | 28 +++-- 3 files changed, 108 insertions(+), 32 deletions(-) delete mode 100644 .changeset/issue-18836-list-view-position-coverage.md diff --git a/.changeset/issue-18836-list-view-position-coverage.md b/.changeset/issue-18836-list-view-position-coverage.md deleted file mode 100644 index 9ddc71ee045..00000000000 --- a/.changeset/issue-18836-list-view-position-coverage.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@objectstack/lint': minor ---- - -Internal hardening of `validate-list-view-field-refs`' own test suite: the criterion for "every field-naming position the rule walks is asserted" is now derived from the rule's own `POSITIONS` / `COLUMN_ENTRY_POSITIONS` tables instead of a hand-maintained row count, so a position added to the rule with no matching test row fails on the commit that adds it. - -No published entry, type or runtime behaviour changes: the derived seam is not re-exported from the package barrel, and `@objectstack/lint`'s built `dist/` is byte-identical to the build that predates it (all nine artifacts, sha256). 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 809e89837db..2561d2c9574 100644 --- a/packages/lint/src/validate-list-view-field-refs.test.ts +++ b/packages/lint/src/validate-list-view-field-refs.test.ts @@ -210,11 +210,20 @@ describe('#14107 — the card\'s five measured positions', () => { } }); +/** + * [#18836] A case's asserted finding path, with the fixture's own `views[0].list` + * prefix and every array index dropped, so it can be compared with a position id. + */ +function casePath(path: string): string { + return path.replace(/^views\[\d+\]\.list\./, '').replace(/\[\d+\]/g, ''); +} + /** * [#18836] The `POSITIONS` position a case's asserted finding path names, or * `undefined` when the path belongs to one of the rule's hard-coded filter - * walks (`filter`, `tabs[].filter`, `userFilters.tabs[].filter`), which no - * table declares and which therefore cannot drift out of one. + * walks — which no table declares, so {@link listViewWalkedPositions} has + * nothing to derive them from. Those are declared and asserted separately, in + * {@link HARD_CODED_FILTER_WALKS}. * * Two arms, because an `entries` position reports at two different paths: at * the entry itself when the author wrote a bare field name @@ -225,12 +234,33 @@ describe('#14107 — the card\'s five measured positions', () => { * of being truncated to its block. */ function positionAsserted(path: string, walked: ReadonlySet): string | undefined { - const at = path.replace(/^views\[\d+\]\.list\./, '').replace(/\[\d+\]/g, ''); + const at = casePath(path); if (walked.has(at)) return at; const entry = at.replace(/\.field$/, ''); return walked.has(entry) ? entry : undefined; } +/** + * [#18836] The rule's three hard-coded filter walks, spelled as + * {@link casePath} normalises the paths they report at. + * + * They are open code, not table rows — `checkListView` calls `checkFilter` on + * `listView.filter`, on `tabs[]` and on `userFilters.tabs[]` — so the position + * set derived from the rule cannot reach them, and the completeness assertion + * below would let their rows be deleted in silence. That is precisely the hole + * the floor this card replaced DID cover, by counting rows. + * + * So they are declared here and asserted EXACTLY: delete one of their rows and + * the list comes up short; give a fourth hard-coded walk a row without adding + * it here and the list comes up long. Together with the derived assertion, every + * row in both tables is then accounted for by one criterion or the other. + */ +const HARD_CODED_FILTER_WALKS = [ + 'filter.field', + 'tabs.filter.field', + 'userFilters.tabs.filter.field', +]; + /** * Every remaining position, with the severity tier it earns. The table is the * readable half of the rule's own POSITIONS table: a position dropped from the @@ -349,27 +379,70 @@ describe('#14107 — every other walked position', () => { // row in one of this file's two tables. A position added to the rule with no // row in either is MISSING from the covered set, and the diff names it. // - // ⛔ It does NOT carry the opposite direction, and saying so is the point - // of this card. `positionAsserted` answers only with positions the rule - // CURRENTLY walks, so a row here for a position the rule has dropped - // contributes to neither side and this assertion stays green. That direction - // belongs to the per-case assertions above — the dropped position stops - // producing a finding and its own `it` fails — which is the first half of - // the docblock above, and both halves were measured on this branch. + // ⛔ THIS assertion does not carry the opposite direction on its own. + // `positionAsserted` answers only with positions the rule CURRENTLY walks, so + // a row left behind for a position the rule has DROPPED contributes to + // neither side here and this one stays green. Two other things catch it, both + // measured: that row's own per-case assertion above stops seeing a finding, + // which is the first half of the docblock; and the sibling assertion below, + // where the stale row matches nothing and comes up as an extra. // - // It does take over the floor's own job: a row deleted from either table - // takes its position off the covered set, so the deletion is red. One seam - // it does not cover — the two positions asserted twice on purpose (`columns` - // and `gantt.tooltipFields`, once as a bare name and once as a `{ field }` - // record) keep their position covered when one of the pair is deleted. + // The floor's OWN job — a row silently deleted from a table — is taken over + // by this assertion and its sibling TOGETHER. The residue is stated here per + // kind of row rather than left to be discovered, because a criterion that + // claims a direction it does not cover is the exact defect this card is + // about. Each one measured on this branch: + // + // - a row for a position no other row covers: deleting it drops the position + // from the covered set ⇒ RED here. + // - a row for one of the rule's three hard-coded filter walks: outside this + // assertion by construction, because those walks are open code and nothing + // derives them ⇒ RED in the sibling assertion below, which is why that one + // exists. + // - one of the two positions asserted TWICE on purpose (`columns` and + // `gantt.tooltipFields`: once as a bare name, once as a record with a + // `field` key): the surviving row still covers the position, so deleting + // either one is ⛔ SILENT — measured, deleting both leaves this file green. + // That seam is disclosed, not closed. Closing it means deriving each + // `entries` position's two legal forms and demanding a row for both, which + // is three rows these tables do not have today. + const assertedPaths = (): string[] => [ + ...MEASURED_CASES.map(([, , path]) => path), + ...cases.map(([, path]) => path), + ]; + it('covers every position the rule walks', () => { const walked = listViewWalkedPositions(); const walkedSet = new Set(walked); - const covered = [...MEASURED_CASES.map(([, , path]) => path), ...cases.map(([, path]) => path)] + const covered = assertedPaths() .map((path) => positionAsserted(path, walkedSet)) .filter((position): position is string => position !== undefined); expect([...new Set(covered)].sort()).toEqual([...walked].sort()); }); + + // [#18836] The other half of the same account, and the half the derived + // assertion above structurally cannot reach: every path the two tables assert + // names either a position the rule walks or one of its declared hard-coded + // filter walks — nothing else. A set, compared in both directions, which + // holds three things the completeness assertion does not: + // + // - SHORT ⇒ RED. Delete a filter-walk row and the set loses a member. All + // three rows measured, one by one. That is exactly the coverage the + // row-counting floor had and the derived assertion cannot reach. + // - LONG ⇒ RED, measured two ways. Remove one of the three declarations + // below and the rows outnumber them. Leave a row behind for a position the + // rule has DROPPED and it matches neither side, so it arrives here as an + // extra — red here as well as in that row's own per-case assertion, which + // is how this assertion ends up carrying the direction its sibling above + // cannot. A fourth hard-coded walk given a row without being declared + // below lands in the same place by the same comparison. + it('accounts for every asserted path, as a walked position or a declared filter walk', () => { + const walkedSet = new Set(listViewWalkedPositions()); + const unaccounted = assertedPaths() + .filter((path) => positionAsserted(path, walkedSet) === undefined) + .map(casePath); + expect([...new Set(unaccounted)].sort()).toEqual([...HARD_CODED_FILTER_WALKS].sort()); + }); }); /** diff --git a/packages/lint/src/validate-list-view-field-refs.ts b/packages/lint/src/validate-list-view-field-refs.ts index fb18bf7f6b0..9d1ab6f07ac 100644 --- a/packages/lint/src/validate-list-view-field-refs.ts +++ b/packages/lint/src/validate-list-view-field-refs.ts @@ -501,22 +501,32 @@ const COLUMN_ENTRY_POSITIONS: Array<{ block: string; key: string; severity: Sev * * - Barrel: `src/index.ts` re-exports this module by NAME (no `export *`), so * an export added here reaches no published entry — 0 occurrences in the - * `export {}` clause of `dist/index.js`, in the `__export` map of - * `dist/index.cjs`, and in all four `.d.ts`/`.d.cts` files, against 1, 1 and - * 2 for the control. + * `export {}` clause of `dist/index.js`, 0 in the `__export` map of + * `dist/index.cjs`, and 0 in all six `.d.ts`/`.d.cts` files, against 1, 1 + * and 2 for the control (whose own 0 in the four `runtime*.d.*` files is + * what those entries declare, not a dead instrument). * - Const vs function: as `const X = Object.freeze([...])` esbuild kept the * initializer as dead weight — 1 occurrence in each of `dist/index.js`, - * `dist/runtime.js` and both `.cjs` siblings, and those four files' bytes - * moved. As the function below it is tree-shaken: 0 occurrences in all - * eight published files, and every one of the nine `dist/` artifacts is - * byte-identical to the build that predates this export. + * `dist/runtime.js` and both `.cjs` siblings. As the function below it is + * tree-shaken: 0 occurrences in all 14 `dist/` artifacts, and 10 of the 14 + * are byte-identical to a build of this package from the pre-export source + * — the four JS bundles and all six type files. + * - ⛔ The other 4 DO move, and `files[]` ships `dist` whole, so the honest + * statement is not "nothing in dist changed": `index.js.map`, + * `index.cjs.map`, `runtime.js.map` and `runtime.cjs.map` differ in + * `mappings` and `names` only, with `sources` equal and this symbol absent + * from `names`. A line offset, not a surface — but a measured one. * * It names positions only — no severity, no shape — so reading it can never * stand in for reading the tables. * * The three filter walks further down (`listView.filter`, `tabs[].filter`, - * `userFilters.tabs[].filter`) are deliberately absent: they are hard-coded - * seams, not table rows, so nothing about them can drift out of a table. + * `userFilters.tabs[].filter`) are deliberately absent: they are open code, not + * table rows, so there is nothing HERE to derive them from. ⛔ Absent from this + * list is not absent from the test's account of itself — the test declares those + * three as an explicit list and asserts it exactly, because a row of theirs + * deleted in silence is the one thing the row-counting floor this replaced did + * cover. */ export function listViewWalkedPositions(): string[] { return [