Repository navigation
Commit cdb327f
feat(metadata-protocol): a refused field removal or type change names the views, forms and dashboard cards that still show the field (#35239)
Fixes #35147
Clause-②: yes (widening: the DESTRUCTIVE_CHANGE answer gains
stillShownBy; a new exported operator-fit table)
Metadata-protocol: added
Skills-docs: none — no skill in `skills/**` teaches the `409
DESTRUCTIVE_CHANGE` save refusal or its `issues[]`. The finding's own
message now names the items, so a client relaying it says them without
being taught.
## 维护者速读
- 改了什么:删除字段或改字段类型被 409 拦下时,回复里的每条 `field_removed`
发现会列出仍在显示该字段的列表视图、表单、数据集、仪表盘卡片、页面、流程和报表(`stillShownBy`,带具体位置);改类型时列出运算符不再适配新类型的列表视图筛选(例如改成数字后的
`contains`)。
- 为什么改:确认删除的人以前只知道「数据会丢」,不知道「哪些界面会坏」;REST 与 MCP 草稿入口现在都能直接说出来,云端 #4620
也等这张卡复用同一个判断。
- 风险与回滚:只在已被拒绝的 409 路径上多读每类元数据一次并跑 `os validate`
那几项检查;读失败时该字段缺省、拒绝照旧。回滚即回退本 PR,无数据或结构迁移。
-
先看:`packages/metadata-protocol/src/destructive-still-shown-by.ts`(按「有字段/无字段」各判一次取差集)、`packages/spec/src/data/filter-operator-field-type-fit.ts`(唯一的运算符适配表,只引用文本运算符门的既有裁决)、`packages/metadata-protocol/src/protocol-save.ts`
中接线的那一处。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol.destructive-still-shown-by.test.ts`,预期 12 个用例全绿,其中删除
`status` 的拒绝同时点名列表视图 `crm_lead_open` 与表单 `crm_lead_edit`。
- 需要你做的:无,席位落地。
## What changes
- **The answer.** `saveMetaItem`'s `409 DESTRUCTIVE_CHANGE` refusal of
an `object` save attaches `stillShownBy` to each `field_removed` and
`field_type_change` finding in `err.issues`. The finding's message ends
by naming the same items. Every door already relays `issues` verbatim,
so no door changed: the REST `PUT` doors relay it as top-level `issues`,
the runtime dispatcher as `details.issues`, and the MCP draft door
(`save_metadata_draft`, `mode: 'draft'`) as `error.issues`. The
duplicate, external-import and unmanaged-import faces carry the message
only, and the message names the items.
- **Removal.** This half is ported from the hosted build door. The stack
is judged with the field and without it, using the checks `os validate`
runs: `validateReferenceIntegrity`, `validateFormLayout` and
`validateWidgetBindings` from `@objectstack/lint`. Every finding the
second run adds is a place that still shows the field. A widget that
reads a dangling dataset dimension or measure is named `via` that
dataset. The saved body is judged as the save would write it, with the
removed fields' stored definitions put back. The three judges are on
lint's root entry only, so they are loaded with a dynamic `import()`
taken only when a `field_removed` finding needs them; the object save
path keeps reaching lint through `@objectstack/lint/runtime` alone
(#4463), and a failed load leaves `stillShownBy` absent.
- **Type change.** A view filter rule names the field by its bare name
and its operator no longer fits the new type. The served `view` listing
never presents an aggregated `{ list, listViews }` container
(`protocol-meta-list-reads.ts` filters them out after expanding stored
ones; measured), so the rules read are a view item's `config.filter`
(the canonical served shape), a flattened list overlay's own `filter`,
and the `userFilters.tabs[].filter` of either, including inside any-of
groups. `filterOperatorFieldTypeFit` judges the fit.
- **One operator-fit table.** `@objectstack/spec/data` gains
`filterOperatorFieldTypeFit` and `FILTER_OPERATOR_FIELD_TYPE_FIT`, with
one row per declared-type door that judges an operator class. Today that
is the text-operator door, referenced by its own exports
(`TEXT_FILTER_OPERATORS`, `textOperatorDoorVerdict`), not re-listed.
`dollarFilterOperatorOf` exports the lowering `canonicalAstOperator`
already folds through. I searched for an existing operator-by-type table
first: the spec filter vocabulary, the ui filter builder and lint. The
engine's declared-type doors live in spec, and the new judgement reuses
the one of them that judges operators. `operatorsForFieldType` in
`ui/packages/components` decides what a dropdown offers, and `packages/`
cannot import it. See Acceptance notes.
- **Shape.** `@objectstack/spec/api` gains
`DestructiveChangeIssueSchema` and `FieldStillShownBySchema`, plus their
author and parsed aliases. The `stillShownBy` describe states what is
computed and what is not seen.
- **Reads.** The code reads one served listing per type (`getMetaItems`)
and only when a finding needs it: views alone for a type change, and
seven types for a removal. It reads no records and no drafts. A listing
that cannot be read, a judge that throws or cannot load, or any throw
while naming the items leaves the key absent, which means "not
computed", and the 409 still throws: the call site catches it, so the
enclosing catch never reads it as "skip the safety check". `[]` means
"computed, shown nowhere".
### Cloud source ported
Read at cloud `origin/main` `c21b3723c41a66a9a3c0c27e0f80b87dec8f86f9`,
read-only:
- `packages/service-ai-studio/src/tools/field-shown-by.ts`: the
judge-twice semantics, path-to-item grouping and the
widget-through-dataset step. These were adapted to this repo's served
listings and nested `issues[]`.
- `packages/service-ai-studio/src/tools/mcp-destructive.ts`: the
`field_shown` entry shape (`type`/`name`/`where`/`via`). Its MCP
`confirm` argument and its card copy are hosted-door behaviour and were
not moved. Its column-summary rule, `view_summary_unfit`, was not moved
either: that question is about aggregates, and the card asks about
filter operators.
Nothing hosted-only, no endpoint, no credential and no tenant data
moved.
## Tests
- New:
`packages/metadata-protocol/src/protocol.destructive-still-shown-by.test.ts`
(12 cases). It drives the real producer and covers a removal named on a
list view and a form, an exact `where`, an empty `[]`, the HTTP relay
(`resolveThrownHttpError`), the MCP draft save shape, a type change
naming a `contains` filter, a served view item at its `config` positions
(columns, filter and a `userFilters` tab filter, on both halves), a
dashboard card named `via` a dataset, absent versus `[]` when a listing
fails, the 409 standing when naming the items throws, every produced
finding parsing through `DestructiveChangeIssueSchema`, and a listing
bound that is positive and does not grow with the item count.
- New:
`packages/metadata-protocol/src/destructive-still-shown-by.lint-entry.test.ts`.
No module in `protocol-save.ts`'s static import closure imports the lint
root as a value; the module uses a dynamic `import()`.
- New:
`packages/rest/src/meta-destructive-still-shown-by-flat-issues.test.ts`.
The REST door's own writer (`handleRouteError`) answers the real
producer's refusal with a non-empty `stillShownBy` in the flat top-level
`issues`.
- New: `packages/spec/src/data/filter-operator-field-type-fit.test.ts`.
It checks the verdict against every `FieldType` x every text operator,
the view-spelling folds, unknown spellings and the formula deferral.
- Updated, as consequences of this change:
`protocol.destructive-gate-reachable-types.test.ts` and the dogfood
`meta-object-unstored-field-removal.dogfood.test.ts` now also expect the
computed `stillShownBy: []` in their exact `issues` assertions.
## Acceptance notes
- **Surface.** The 409 is thrown in `protocol-save.ts`, not
`protocol-write-face.ts`; the claim named the wrong file, and seat
amendment 6987803352 widened the file surface to `protocol-save.ts` (Q1
answered A). The wiring there is 10 lines: one call, plus `getMetaItems`
in the host pick. `protocol-write-face.ts` is untouched. The reader
lives in `destructive-still-shown-by.ts`, outside the `protocol-*`
split-module family. It is not a moved body, and a `protocol-*` name
puts its lint collection key `objects` under the `objects`-tolerance
scan.
- **Second table in the UI.** `operatorsForFieldType`
(`ui/packages/components/src/custom/filter-builder.tsx`) is a dropdown's
offer table, not a refusal judge. It answers a different question.
Pointing it at `filterOperatorFieldTypeFit` would be a `ui/` change
outside this card.
- **Not seen.** Filters outside views, comparands that stop fitting a
new type, a filter another door refuses (such as any filter on a field
retyped to `formula`), dotted paths, drafts, and item types not listed.
All of this is stated in the describe, together with the literal
`(root)` in `where` and an item appearing in more than one entry.
- **Contract review 6989169773.** S1 closed as above: the describes and
the changeset name the served paths (`config.columns[1]`, `columns[1]`),
and the unreachable `list` / `listViews.*` rungs and the container-name
fallback are gone. N1, N2, N7 and N8 are taken; N3 to N6 are recorded
only. The L1 note on the lint entry is taken too: the root is loaded
lazily, and a lint-entry test pins it. `@objectstack/lint/runtime` does
not export the three judges, and adding them there would mean editing
`packages/lint/src/**`, which is outside this claim.
- **Merge.** `#35240` landed, so `origin/main` `b02484e13a` was merged
into the branch through `scripts/pm/os-regen-merge.sh`. Afterwards the
generated chain was rebuilt on the committed merge: `gen:schema`,
`gen:export-origins`, `gen:declaration-map`, `gen:api-surface`,
`gen:strictness-ledger` and `gen:docs`, with `check:generated` reporting
all 14 current. Against main, the branch's generated diff holds only
this PR's rows.
- `packages/spec/authorable-surface/api.json` moved: 9 rows for the two
new response schemas. That is a protocol addition, so the declaration is
`Metadata-protocol: added` and the changeset grades `@objectstack/spec`
`minor` (seat amendment 6987803352, Q2);
`@objectstack/metadata-protocol` stays `patch`.
## Verification
<details><summary>Fix round: red on the previous head, N1 ablation,
dogfood file</summary>
Red leg: `destructive-still-shown-by.ts` and `protocol-save.ts` were
restored from `8ee295be69`. The pins went 4 failed, 10 passed of 14: the
two lint-entry cases, the 409-stands-on-throw case, and the
`userFilters` tab filter on a type change. The 10 that passed pin
behaviour that this round leaves unchanged. Restored with `git checkout
HEAD`; blob hashes matched HEAD and `git diff HEAD` was empty.
N1 ablation (source-resolved; `metadata-protocol` tests import
`./protocol.js`): `scripts/ablation-replace.mjs` put `throw error;` into
the call-site catch in `protocol-save.ts`, and the anchor went 1 to 0 on
disk. The pin went 1 failed, 11 passed: the 409-stands-on-throw case. On
restore, the blob matched HEAD `d5b5ad9a9a45`.
Dogfood: after building the dogfood dependency closure,
`meta-object-unstored-field-removal.dogfood.test.ts` ran under the lock
with `VERDICT command-exit 0`: 1 file, 3 tests passed.
</details>
<details><summary>Red on main's wiring, green with it</summary>
The red leg restored `protocol-save.ts` from `ec227fc7b1`: 5 failed, 1
passed of 6. The one pass is the read-bound case, which passes trivially
with no reads. Restored to HEAD, with a hash match: 6/6 passed.
</details>
<details><summary>Ablation (dist-resolved, spec rebuilt both
legs)</summary>
The mutation was `verdict === 'door-refusal' ? 'unfit'` becoming
`verdict === 'ABLATED_35147' ? 'unfit'` in
`filter-operator-field-type-fit.ts`, done via
`scripts/ablation-replace.mjs`. `ablation-dist-preflight` found the
marker in 2 built files, and the pin went 1 failed, 5 passed: the
type-change case. On restore, the blob matched HEAD, the spec was
rebuilt, preflight with `--absent` found the marker in none of 608
files, the pin went 6/6, and the whole-tree `git status` was clean.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbXGvw43spR79ztEvWt -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 65b67be commit cdb327f
24 files changed
Lines changed: 1281 additions & 11 deletions
File tree
- .changeset
- content/docs/references
- api
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- metadata-protocol/src
- qa/dogfood/test
- rest/src
- spec
- api-surface
- authorable-surface
- declaration-map
- export-origins
- json-schema.manifest
- src
- api
- data
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
0 commit comments