Skip to content

feat(lint): report a declared field with zero consumers across the registered metadata roots (#15922) - #16323

Merged
baozhoutao merged 2 commits into
mainfrom
claude/issue-15922-lint-field-zero-consumers
Sep 6, 2026
Merged

baozhoutao merged 2 commits into
mainfrom
claude/issue-15922-lint-field-zero-consumers

Conversation

@baozhoutao

Copy link
Copy Markdown
Collaborator

Fixes #15922

Clause-②: yes

What this adds

A new advisory rule in @objectstack/lint, field-no-consumers (validateFieldConsumers), registered in AUTHORING_RULES so os validate, os build and os lint all run it. It reports, as a warning, an object field that nothing in the stack reads or displays — the field-level remainder of #4698 (that card is not addressed here; this is the platform half of the hotcrm#1543 ruling F, verbatim 「1543 选 F」, under which HotCRM retired its own scanner).

The retired scanner was read as design input, not ported: its judgements (object-aware resolution, the consumer/carrier split, prose is not a read, a flow WRITE is a carrier) are carried; its implementation is not. The rule is built on the package's shared primitives — collectionEntries (positional paths on both collection shapes), recordsOf, injectedColumnsFor, and the spec's resolveDisplayField.

Derived judgments (for the in-seat contract review)

  • New accept/report set. Nothing is refused. A field is reported when it has zero behaviour sites and zero display sites across the scanned roots; carrier sites never rescue it. Exempt: registry-injected system columns an author re-declared (injectedColumnsFor, i.e. resolveInjectedSystemColumns in @objectstack/spec/data), the record title field (resolveDisplayField, the ADR-0079 nameField ladder — packages/spec/src/data/display-name.ts:220), and master_detail fields (ADR-0035 — packages/objectql/src/master-detail.ts names cascade delete, controlled_by_parent sharing, roll-ups and inline grids as readers of the relationship). A stack that declares no consumer root at all (objects only, or objects plus carriers) is not judged.
  • Public surface gained. validateFieldConsumers, FIELD_NO_CONSUMERS, FIELD_CONSUMER_ROOTS, FIELD_CARRIER_ROOTS; types FieldConsumerFinding, FieldConsumerVerdict, FieldConsumerSeverity. The finding shape is the standard six keys plus object, field, verdict, carriers[] (config paths a removal must clean) and rootsScanned[].
  • Wiring. tier: 'advisory', input: 'normalized', commands: ALL, surfaces: CLI_ONLY with surfaceReason: RUNTIME_NEEDS_FULL_SNAPSHOT — the sharpest instance of that reason in the table: the verdict is the ABSENCE of a reference across views / pages / flows / datasets, none of which the per-write snapshot carries, so on an object write it would report every field of the written object as inert.

Taxonomy decision — one rule id, verdict on the finding

HotCRM's scanner produced live / display-only / inert with a separate carrier count (its code has three verdicts, not four). Decided on the four axes:

  • 实际业务需求 — measured on the adjudications the scanner fed (hotcrm#1198 / feat(spec): add fieldGroups MVP to ObjectSchema #1199): the actionable difference between rows was what a removal must clean, which is the carrier site list, not a second rule id. display-only is the ordinary state of most fields (a drawn phone) and the scanner itself listed it only under --all — reporting it would be noise, so it is not a verdict here.
  • 项目长远合理性 — the taxonomy stays machine-readable as data on the finding (verdict: 'inert' | 'carrier-only', carriers[]); if a consumer ever needs separate ids the split is additive, whereas retiring two ids later is a breaking change.
  • 防 AI 犯错 — one id, one fix sentence: give it a consumer or remove it and clean the listed carriers. Two ids invite reading carrier-only as "fine" and laundering the inert class through it.
  • 创业阶段不扩散需求 — the smallest exported surface that carries the whole reading.

Severity: warning, per triage's placement; a refusal would narrow the authorable surface (today-valid metadata would start being refused) and is the maintainer's call, not this PR's. The rule never emits error (the wiring guard reads its source to hold that).

Boundaries, stated in the rule and in every finding

  • Roots scanned, in rootsScanned and the hint: consumers objects, views, pages, apps, flows, dashboards, reports, datasets, actions, hooks, jobs, emailTemplates, agents, tools, skills, apis, webhooks, sharingRules, analyticsCubes; carriers translations, data, mappings, permissions. test/ fixtures are never scanned — the boundary that made hotcrm#1543 a decision is written down rather than left as lore.
  • Object-aware by construction: a reference is credited to the object whose declaration encloses it (object / objectName / targetObject / data.object / config.objectName / list.data.object / a dataset resolved to its object / a map keyed by object name / a flow's trigger object), and only when that object declares the token; in a text blob the nearest preceding mention of a declared object is a second candidate. The same name on two objects gets two verdicts, and the finding names the other objects so a per-object verdict is never mistaken for a name-level one.
  • Carriers never count: a translation label, a seed value, an import-mapping column, a field-level permission grant, a flow that only writes the field, prose naming it. An interpolation token inside prose ({record.x} in a notify message) is a read.
  • Under expression-bearing keys (source, expression, condition, …) a bare identifier is a read (total_amount >= 5000 in a flow trigger); elsewhere only reference shapes count (record.x, a quoted name, a {x} token, an object-literal key).

Corpus reading — examples/* at ad909f370

app objects fields findings inert carrier-only
app-crm 6 49 10 4 6
app-showcase 24 210 63 32 31
app-todo 1 18 5 0 5
app-multi-package 2 5 3 3 0

Spot-checked against the source rather than trusted: app-crm's crm_account.* / crm_contact.* rows are real (that example ships no view for either object; the views index exports Opportunity, Lead and Activity only), crm_opportunity.days_to_close is a formula nothing draws, showcase_task.sync_status is only ever WRITTEN by a flow, and showcase_field_zoo.f_image is named nowhere outside its declaration. Two spot checks found walker misses and were fixed with pins: the cel tagged-template envelope's source text was being skipped (quantity/unit_price on the CRM line item), and a bare identifier in a trigger condition was not a reference shape (total_amount on the showcase expense report).

packages/apps/* (setup / studio / account) are plugins, not authored stacks — their own tests say so — so there is no stack to run the rule over; no reading is invented for them. HotCRM's current main was not re-derived: the hotcrm repository is outside this session's scope (its retired scanner source was readable, its current stack was not loaded), so no HotCRM count appears here and the historical 15 is not used as an acceptance number.

These findings are data, not things this PR fixes. The one design question the corpus raises is recorded below for the maintainer.

Tests and gates — pinned to ad909f370

  • packages/lint/src/validate-field-consumers.test.ts — 25 tests: the five-verdict fixture with the same-name pair (assert by rule id AND declaration path), positional path on the array shape, negative control (all consumed → zero findings), the skip gate, each derived exemption both ways, one credit per root, carriers never rescue, prose vs template, bare identifier in an expression, and registry wiring end to end through runAuthoringRules on all three commands.
  • pnpm --filter @objectstack/lint test — Test Files 100 passed (100) · Tests 3405 passed (3405); pnpm --filter @objectstack/lint typecheck — tsc clean and check:test-typecheck: OK.
  • Ablation, from the committed state: mutated the verdict guard so a carrier rescues a field (anchor count 1→0, marker 0→1 proven on disk), suite went red on exactly the five carrier-sensitive assertions (5 failed | 20 passed), restored with git checkout HEAD -- path, blob hash equal to HEAD's and git diff HEAD empty. The test imports the rule from src (relative .js specifier, no exports hop), so no dist preflight applies.
  • Downstream consumers of the rule table, tested against a rebuilt lint dist: @objectstack/cli unit tier 180 passed (180) (one pin file first refused on an unbuilt CLI, then measured green after pnpm --filter @objectstack/cli build; the integration tier is declared to CI), @objectstack/metadata-protocol 166 passed | 2 skipped, @objectstack/platform-objects 35 passed, @objectstack/example-crm 5 passed, @objectstack/example-todo 4 passed.
  • node scripts/pm/dispatch-gates.mjs --ran at ad909f370: 82 derived, 82 run, 0 UNRUN. Two of those runs are NOT MEASURED, not green: pnpm check:type-check-debt and pnpm check:dual-build-cjs-loads both exit 3 PREREQUISITE NOT MET (unbuilt dists in this worktree). Every other family exited 0, including check:docs-transcript-drift after the second commit.
  • Second commit: check:docs-transcript-drift holds four hand-written os validate / os build transcripts under content/docs/ equal to what authoringRulesFor() derives; the new registry entry moves that count from 42 to 43, so those four lines moved with it.

Changeset: .changeset/lint-field-no-consumers.md — @objectstack/lint minor.

Open question for the maintainer (not a blocker)

Should default-layout rendering count as display? A form view with no declared sections renders every field, and a nav-exposed object gets a default list and detail — so on the showcase, roughly half the rows are fields drawn only by a default layout. The rule reads declared metadata only (the same definition HotCRM's adjudicated ledger used, and AGENTS.md's "explicit composition over default magic"), and states the boundary in every finding. Recommendation: keep declared-only, and read the corpus counts as the volume cost of that choice; if the maintainer prefers the default-layout credit, it is a bounded follow-up (credit every non-hidden field of an object that has a section-less form view or a nav entry).


🤖 Generated with Claude Code

https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8


Generated by Claude Code

…gistered metadata roots

New advisory rule `field-no-consumers` (`validateFieldConsumers`): an object
field that nothing in the stack reads or displays is a warning on validate,
build and lint. Object-aware (the same name on two objects gets two
verdicts), carriers (translations, seeds, mappings, permission grants, flow
writes, prose) never count, and the finding carries the verdict, the carrier
paths a removal must clean, and the roots scanned. Exemptions are derived from
the spec: injected system columns, the ADR-0079 title field, master_detail.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8
…o-consumers is registered

`check:docs-transcript-drift` holds the four hand-written `os validate` /
`os build` transcripts equal to what `authoringRulesFor()` derives; the new
registry entry moves that count from 42 to 43.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/lint, touching 111 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/lint/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

74 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json ac6213ee95e49fa62af824b60a062b3f97dfc87f.

⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/lint/src/index.ts) — pages documenting those are invisible to this run
  • 2 anchor(s) matched too much of the corpus to be a work list: objectName (literal, 34 pages), sharingModel (literal, 39 pages)
  • 19 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 56 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 102 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 5 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json ac6213ee95e49fa62af824b60a062b3f97dfc87f → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 93af4788b79249c26c60aaffc638d3c23ca5f257 — the merge of head ad909f3709ea7721cd8fca35c4ee82fec04e7c0a into base ac6213ee95e49fa62af824b60a062b3f97dfc87f, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 93af4788b79249c26c60aaffc638d3c23ca5f257 && git checkout 93af4788b79249c26c60aaffc638d3c23ca5f257
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin ac6213ee95e49fa62af824b60a062b3f97dfc87f ad909f3709ea7721cd8fca35c4ee82fec04e7c0a && git checkout -B drift-repro ac6213ee95e49fa62af824b60a062b3f97dfc87f && git merge --no-ff ad909f3709ea7721cd8fca35c4ee82fec04e7c0a

node scripts/docs-audit/affected-docs.mjs --json ac6213ee95e49fa62af824b60a062b3f97dfc87f

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs ac6213ee95e49fa62af824b60a062b3f97dfc87f → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@claude claude Bot added needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides and removed needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides labels Sep 6, 2026
@baozhoutao
baozhoutao marked this pull request as ready for review September 6, 2026 14:45
@baozhoutao
baozhoutao enabled auto-merge September 6, 2026 14:45
@baozhoutao
baozhoutao added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit a87163c Sep 6, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-15922-lint-field-zero-consumers branch September 6, 2026 15:12
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
…nd the inline grid's line-position field (objectstack-ai#32276)

domain:spec#3 · os-support-ai · session_01WGufzh7cM8EmUX4T2CBNHX

<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBD51tXwx3Q3tVXsAku498wA)_

Closes objectstack-ai#32256

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 改了什么:`field-no-consumers` 不再把两类其实有人读的字段报成「没人用」:① 权限集行级安全策略
`rowLevelSecurity[].using` / `.check`(以及对象自己的
`defaultRowScope`)里按字段过滤或校验的字段;② 内联明细表拖拽排序时写入、加载时按它排序的「行序字段」(如
`position`)。spec 新增一个纯函数
`deriveInlineGridSortField`,按渲染器同一规则算出这个字段,名单本身仍不公开。showcase
白名单里为这两个误报加的两条随之删除。
- 为什么改:showcase 上 `showcase_invoice.owner`(被 `invoice_own_rows` 的
`using` 每次查询读取)和 `showcase_invoice_line.position`(发票明细表的行序字段)被误报;PR
objectstack-ai#32233 只能先把它们列进白名单。
- 风险与回滚:只是一条建议级(warning)lint 少报误报,不拒收任何元数据;spec 只多一个导出函数,不改任何
schema。权限集里除行级策略以外的路径(字段级授权等)仍算「只携带不读取」。回滚即 revert。
- 先看:① `packages/lint/src/validate-field-consumers.ts` 的
`isRlsPredicateSite` 与 `creditInlineGridSortField`(两处计入点);②
`packages/spec/src/data/inline-grid-columns.ts` 的
`deriveInlineGridSortField`;③
`examples/app-showcase/test/author-time-advisories.test.ts` 删掉的两条白名单。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/validate-field-consumers.test.ts -t 32256`,预期两组共 16 条全绿(行级策略 9
条、行序字段 7 条)。
- 需要你做的:无,席位落地。

## What changes

- **`packages/lint/src/validate-field-consumers.ts`, credit 1: a
row-level security predicate is a read.** `CARRIER_ROOTS` still lists
`permissions`, and every path under it stays a carrier except a policy's
two predicate clauses, `permissions[].rowLevelSecurity[].using` and
`.check`. Those are now `behaviour` sites, and their text is scanned as
an expression (every bare identifier a candidate), because a policy
names its fields as bare CEL identifiers (`owner ==
current_user.email`). The policy's `object` is the context the walk
already resolves, so the field is credited on the object the policy
filters, never on another object declaring the same name.
- `using` is compiled into the row filter of every read, update and
delete the policy governs (ADR-0056 D4); `check` is matched against
every row an insert or update writes (ADR-0058 D4). Both read the field
on every request, as a sharing-rule `condition` (already credited) does.
- The key names are typed against the spec rather than read from it:
`'rowLevelSecurity' satisfies keyof PermissionSet`, and `['using',
'check'] satisfies readonly (keyof RowLevelSecurityPolicy & keyof
DefaultRowScope)[]`. The spec exports no list of a policy's predicate
clauses (its own refinement names the same two members by hand), and
`satisfies` turns a rename there into a typecheck failure here instead
of a credit that quietly stops matching.
- **Same class, fixed in place:** an object's `defaultRowScope`
(`DefaultRowScopeSchema`, enforced by `plugin-security`'s
`object-default-row-scope.ts`) is the same policy with the object
implied. It was already a behaviour site under `objects`, but `using` /
`check` were not scanned as expressions, so a field only it filters on
was reported `inert` (repro in Acceptance notes). The same predicate
test now covers `objects[].defaultRowScope.using` / `.check`, keyed by
`'defaultRowScope' satisfies keyof ServiceObject`.
- **Credit 2: an inline grid's line-position field is a read.** The
renderer resolves, on every inline grid, the child field it stamps each
line's position into on drag-reorder and orders the child rows by
(`deriveDetail` in `ui/packages/plugin-form/src/deriveMasterDetail.ts`;
`MasterDetailForm.tsx` sets `sortField` from it on both the
authored-columns and the derived branch and adds it to the child fetch's
`$orderby`). No column draws it: both spec derivations skip the
sort-position names. The rule now credits that field as `behaviour`
through the spec's own derivation on each carrier that draws a grid: a
`lookup` / `master_detail` field that sets `inlineEdit` (authored
`inlineColumns` or derived), and every `subforms` / `details` collection
entry. A `record:line_items` panel is not credited: it does not go
through `deriveDetail`.
- **`packages/spec/src/data/inline-grid-columns.ts`: new
`deriveInlineGridSortField(def)`** on `@objectstack/spec/data`. The
renderer's rule, reproduced exactly: the first child field, in field-map
order, whose name is one of `INLINE_GRID_SORT_FIELDS`; no flag or type
is consulted; `undefined` when the child declares none or carries no
field map. `INLINE_GRID_SORT_FIELDS` stays private (no barrel re-export,
no subpath), as its module says. The module note gains a section on it.
Generated `api-surface/data.json` and `export-origins/data.json` each
gain the one line.
- **`packages/lint/src/rule-explanations.ts`.** `os explain
field-no-consumers` lists both reads among the consumers, and the
carrier paragraph says "a field-level permission grant".
- **`examples/app-showcase/test/author-time-advisories.test.ts`.** The
two `field-no-consumers` allow-list entries objectstack-ai#32233 added for these false
positives (`showcase_invoice.owner`, `showcase_invoice_line.position`)
are deleted, with their section heading. The list is two-directional, so
it now requires both findings to be gone.
- **`.changeset/32256-field-consumers-rls-and-grid-position.md`.**
`patch` for `@objectstack/lint` and `@objectstack/spec`, with both
declaration lines.

Responsibility: `CARRIER_ROOTS` with `permissions`, and the branch where
a carrier root decides the bucket before anything else is asked, came in
with the rule itself (`a87163c89b`, objectstack-ai#16323). The later inline-grid
credits (objectstack-ai#20929, objectstack-ai#20951, objectstack-ai#21091) covered the columns, the join key and
the row form, never the line-position field; the renderer derives that
field from the child since objectui#11070, after the authored
`sortField` was retired.

## Why

objectstack-ai#32256: the QA run for objectstack-ai#32168 found both showcase findings (class a) and
objectstack-ai#32233 allow-listed them as a workaround. The card asks for both
credits, a negative for each, and the two entries off once objectstack-ai#32233
merged. It merged as `d391babc`; this branch is on it. Seat ruling on
the card (claim amendment 2): route A, one spec helper;
`INLINE_GRID_SORT_FIELDS` stays private.

Prior rulings read (`check-prior-rulings.mjs --card 32256 --terms
field-no-consumers,CARRIER_ROOTS,rls,inline-grid`, 35 hits): ADR-0056 D4
and ADR-0058 D4 decide that `using` and `check` are compiled and
enforced, which is why both clauses count as reads; ADR-0058 D5
(security predicates fail closed) changes nothing here. The other hits
(ADR-0054 §3, ADR-0055 §1/§4, ADR-0056 D2/D3/D9, ADR-0058 D1/D6) touch
RLS enforcement, not this rule.

## Tests

All new lint pins are top-level `describe` blocks in the rule's existing
harness, `packages/lint/src/validate-field-consumers.test.ts`, placed
above the two `objectstack-ai#22161` blocks that must stay last (they read what the
cases above fired).

**`[objectstack-ai#32256] … a row-level security predicate reads the fields it
names`** (9 cases). Two objects (`inv`, `other`) both declare `owner`;
`inv` also declares `region`.

- Baseline: no policy, `owner` reported on both.
- `using` (`owner == current_user.email`) credits `inv.owner`; `check`
on an `update` policy credits it the same way.
- A compound `using` credits every field it names (`owner`, `region`).
- A name-keyed `permissions` map reads the same as the array shape.
- An object's `defaultRowScope` with `using` and `check` credits
`inv.region` and `inv.owner`.
- ⛔ A field-level grant beside the policy stays a carrier: `inv.region`
is `carrier-only` with exactly
`permissions[0].objects.inv.fields.region`.
- ⛔ The predicate credits only the object it filters: `other.owner`
stays `inert`.
- ⛔ The same predicate text under an ordinary object key (`description`)
credits nothing.

**`[objectstack-ai#32256] … an inline grid reads its line-position field`** (7 cases).
The child `lin` declares `position` then `sort_order`.

- Baseline: a `lookup` with no `inlineEdit` leaves both sort-named
fields reported.
- A grid with authored `inlineColumns: [{ name: 'qty' }]`, and one with
derived columns, both credit `position` only.
- A form view `subforms` entry and an `object-master-detail-form`
`details` entry credit it on their `childObject`.
- The field is the first sort name in the child's FIELD order: with
`sort_order` declared first, `sort_order` is credited and `position`
reported.
- ⛔ The child's second sort-named field stays reported, and so does a
sort-named field on the parent.

**`packages/spec/src/data/inline-grid-columns.test.ts`,
`deriveInlineGridSortField`** (5 cases): resolves the declared name;
first match in field order, not list order; flags and type are not
consulted; the resolved name is one both derivations leave out; a
look-alike name (`order`, `rank`) and a missing field map resolve
`undefined`.

<details><summary>Runs at the final head (c448e8e)</summary>

```text
pnpm --filter @objectstack/lint typecheck && pnpm --filter @objectstack/lint test   (under os-verify-lock)
 Test Files  199 passed (199)
      Tests  8427 passed (8427)
os-verify-lock: VERDICT command-exit 0

pnpm --filter @objectstack/spec typecheck && pnpm --filter @objectstack/spec test   (spec unchanged since 297e59f)
 Test Files  833 passed (833)
      Tests  26580 passed | 1 todo (26581)
os-verify-lock: VERDICT command-exit 0

examples/app-showcase: pnpm exec vitest run test/author-time-advisories.test.ts
      Tests  2 passed (2)
```
</details>

### Ablations

Each ran from a committed head through `scripts/ablation-replace.mjs` on
`packages/lint/src/validate-field-consumers.ts` (the suite imports the
rule from source, so no rebuild is involved). Every restore was checked:
`git diff HEAD` empty afterwards.

<details><summary>A: drop the permission-set credit (`if
(isRlsPredicateSite(root, segments)) return 'behaviour';` deleted): 4
red</summary>

```text
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 62b396f -> 367a7c93f76f
     × a `using` predicate reads its bare field, on the object the policy names
     × a `check` predicate is the same read, on the row a write produces (ADR-0058 D4)
     × every field a compound predicate names is read
     × a name-keyed permission set map reads the same way
      Tests  4 failed | 171 passed (175)
```
</details>

<details><summary>B: drop the relationship grid's sort-field credit (the
`creditInlineGridSortField(…, `${fieldPath}.inlineEdit`)` call deleted):
4 red</summary>

```text
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 62b396f -> 0f9c8109e183
     × a grid with authored `inlineColumns` reads `position`, which no column draws
     × a grid with derived columns reads it too (the derivation skips it as a column)
     × the line-position field is the first sort name in the child's FIELD order, not the list's
     × ⛔ a child field the grid does not derive stays reported, and so does the parent's own sort-named field
      Tests  4 failed | 171 passed (175)
```
</details>

<details><summary>C: drop the `defaultRowScope` arm (replaced by
`false`): 1 red</summary>

```text
ablation-replace: ok mutation landed: anchor 1 -> 0, blob aaac992 -> 8cdb8220969c
     × an object's `defaultRowScope` is the same policy, on the object that declares it
      Tests  1 failed | 176 passed (177)
```
</details>

## Acceptance notes

- **`current_user.*` paths.** In an RLS predicate, `current_user.email`
matches the rule's `.x` reference shape, so a field named `email` on the
policy's object would also be credited. That is the scan every
expression site already gets (a sharing-rule `condition` included) and
the quiet direction the rule's header chooses ("under-crediting is the
noisy direction"). Not narrowed here.
- **A field permission's `when`**
(`permissions[].objects.X.fields.Y.when`, a CEL row condition on the
edit vote) is still a carrier, as the card asks ("every other path under
`permissions` stays a carrier"). It does read the fields it names;
whether that is a consumer is not decided here. carrier: none.
- **`defaultRowScope` repro (in-place fix).** Before this branch,
`validateFieldConsumers({ objects: [{ name: 'o', defaultRowScope: {
operation: 'select', using: "region == 'emea'" }, fields: { name: {
type: 'text' }, region: { type: 'text' } } }], views: [{ list: { data: {
object: 'o' }, columns: [] } }] })` returned `region` as `inert`
(measured on the built lint dist, `[["region","inert"]]`). The four
in-place conditions hold: same defect class, the same predicate test, a
file this claim holds, the same gate family. The showcase declares no
`defaultRowScope`, so the showcase readings do not move.
- `packages/spec/src/data/inline-grid-sort-fields.ts` still says "Two
readers here"; the new helper sits in one of them
(`inline-grid-columns.ts`), so the sentence stays true and the file is
untouched.

## Verification

**`os validate --json` on `examples/app-showcase`, before and after.**
Before = this branch with `validate-field-consumers.ts`,
`rule-explanations.ts` and `inline-grid-columns.ts` checked out from
`origin/main` (`d391babc`) and `@objectstack/spec`, `@objectstack/lint`,
`@objectstack/cli` and `@objectstack/rest` rebuilt (the CLI and `rest`
bundle the lint rules); after = the final head, the same four rebuilt.
Findings compared as whole JSON objects.

```text
before  31 warnings  field-no-consumers 3   (+ approval-approvers-may-resolve-empty 11, security-rollup-source-unreadable 9, …)
after   29 warnings  field-no-consumers 1   (every other rule's count identical)
gone:   field-no-consumers · object "showcase_invoice" · field "owner"
        field-no-consumers · object "showcase_invoice_line" · field "position"
new:    0
```

The remaining `field-no-consumers` is `showcase_semantic_zoo.notes`,
allow-listed on purpose. With the two allow-list entries removed,
`test/author-time-advisories.test.ts` fails on the before build (`new
author-time advisories: … [ "field-no-consumers · object
\"showcase_invoice\" · field \"owner\" · objects[].fields.owner", "…
showcase_invoice_line … position …" ]`) and passes on the after build
(2/2).

The same two disappeared, and nothing else moved, when first measured at
the claim's base `a2bdaea1` (before objectstack-ai#32233 merged): 77 → 75 warnings,
field-no-consumers 49 → 47.

**Gates.** All 91 families `node scripts/pm/dispatch-gates.mjs
--commands` derives for this diff ran locally at the final head
`c448e8e3eb`, each with its exit code captured before any pipe, and
every one exited 0. `--ran` reconciliation: "91 derived famil(ies)
accounted for — 91 run, 0 NOT-MEASURED (a DERIVED zero — all 91 recorded
an exit code and none of them is 3)". The record is `gates-ran.list`
beside this body's draft. `check-changeset-no-major` ran with this body
as the `--event` payload: "LEVEL AXIS: this PR declares clause-② `no`
and metadata-protocol `none`, and it introduces no changeset entry
graded `minor` or above". `check:dual-build-cjs-loads` first answered
`PREREQUISITE NOT MET` (exit 3: six packages had no dist), then a load
failure while other gates were rebuilding dists beside it; after
building the six and with nothing else running it passed ("122 published
require entry point(s) across 72 package(s) load"). Local-only:
`check:skill-frame-freshness` green; `check:dev-prereqs` reports this
box's `ui/**` packages unbuilt, a reading about the container, not the
diff. `pnpm --filter @objectstack/spec check:generated`: "All 14
generated artifacts are up to date".

**Not run locally, declared to CI:** the vitest `repo` project (`Test
Core`), the repo-wide `pnpm lint`, the full dogfood battery (no `!` in
the title, no `(narrowing)` arm).

---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzejML1KeqT77XQrAiu)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants