Skip to content

Commit cdb327f

Browse files
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
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/metadata-protocol': patch
4+
---
5+
6+
feat(metadata-protocol): a refused field removal or type change names the views, forms and dashboard cards that still show the field
7+
8+
Clause-②: yes (widening: the DESTRUCTIVE_CHANGE answer gains stillShownBy; a new exported operator-fit table)
9+
Metadata-protocol: added
10+
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.
11+
12+
The `409 DESTRUCTIVE_CHANGE` refusal of an `object` save said what data the change loses. It now also says what breaks on screen. Each `field_removed` finding carries `stillShownBy`: the views, forms, datasets, dashboards, pages, flows, reports and objects that still reference the field, at the positions that name it, as the served listing presents each item (`config.columns[1]` on a view item, `columns[1]` on a flattened list overlay, `widgets[3]` through a dataset). Each `field_type_change` finding carries the view filter rules whose operator the new type no longer fits, for example a `contains` filter on a field changed to `number`: a view item's `config.filter`, a flattened overlay's `filter`, and the `userFilters.tabs[].filter` of either. The finding's message names the first five items and counts the rest, so a door that relays only the message says it too. The save edits none of them.
13+
14+
- The answer rides the refusal's `issues[]`, which every door already relays verbatim: the REST `PUT /api/v1/meta/...` doors (`issues`), the runtime dispatcher (`details.issues`) and the MCP draft door (`error.issues`). No door changed.
15+
- It is computed from the environment's served metadata, one listing per type, only when a finding needs it. No record and no draft is read. When it cannot be computed (a listing cannot be read, a judge throws or cannot be loaded) `stillShownBy` is absent ("not computed"), and the refusal still stands; `[]` means "computed, shown nowhere".
16+
- A removal is judged by the checks `os validate` runs (`@objectstack/lint`'s reference-integrity suite, form-layout check and widget-binding check), with the field and without it. A position those checks do not read is not seen. The spec describe on `DestructiveChangeIssueSchema.stillShownBy` states exactly what is and is not seen.
17+
- `@objectstack/spec/data` exports `filterOperatorFieldTypeFit(operator, field)` and its table `FILTER_OPERATOR_FIELD_TYPE_FIT`: the one place that judges which filter operator fits which field type. An operator is unfit only where a declared-type door refuses it. Today that is the text-operator door (a text operator over a type that can never store a string, `INVALID_FILTER` 400), referenced rather than re-listed. `dollarFilterOperatorOf(op)` lowers a view, alias or infix operator spelling to its `$` form; a `$` spelling is returned as written, and an unknown spelling answers `undefined`.
18+
- `@objectstack/spec/api` declares the answer's shape: `DestructiveChangeIssueSchema` and `FieldStillShownBySchema`.

‎content/docs/references/api/protocol.mdx‎

Lines changed: 42 additions & 3 deletions
Large diffs are not rendered by default.

‎content/docs/references/index.mdx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Protocol reference — every schema by module
33
navTitle: Protocol Reference
4-
description: Every schema published by @objectstack/spec — 1698 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1700 schemas across 14 protocol modules
55
---
66

77
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
@@ -21,7 +21,7 @@ counts are sums of the rows they head. Regenerate with
2121
| Module | Pages | Schemas | Description |
2222
| :--- | ---: | ---: | :--- |
2323
| [AI Protocol](/docs/references/ai) | 14 | 84 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. |
24-
| [API Protocol](/docs/references/api) | 37 | 519 | REST contracts, endpoints, routing, realtime, batch, discovery. |
24+
| [API Protocol](/docs/references/api) | 37 | 521 | REST contracts, endpoints, routing, realtime, batch, discovery. |
2525
| [Automation Protocol](/docs/references/automation) | 16 | 82 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. |
2626
| [Data Protocol](/docs/references/data) | 35 | 188 | Objects, fields, queries, filters, datasources and drivers — the ObjectQL layer. |
2727
| [Identity Protocol](/docs/references/identity) | 5 | 27 | Users and accounts, organizations, positions, SCIM provisioning. |
@@ -34,7 +34,7 @@ counts are sums of the rows they head. Regenerate with
3434
| [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. |
3535
| [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. |
3636
| [UI Protocol](/docs/references/ui) | 16 | 180 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37-
| **Total** | **219** | **1698** | 14 protocol modules |
37+
| **Total** | **219** | **1700** | 14 protocol modules |
3838

3939
---
4040

@@ -65,7 +65,7 @@ Agents, tools, skills, RAG and knowledge sources, model registry, conversations.
6565

6666
## API Protocol
6767

68-
**Source:** `packages/spec/src/api/` · **Import:** `@objectstack/spec/api` · **37 pages, 519 schemas**
68+
**Source:** `packages/spec/src/api/` · **Import:** `@objectstack/spec/api` · **37 pages, 521 schemas**
6969

7070
REST contracts, endpoints, routing, realtime, batch, discovery.
7171

@@ -95,7 +95,7 @@ REST contracts, endpoints, routing, realtime, batch, discovery.
9595
| [`package-api-assembled.zod.ts`](/docs/references/api/package-api-assembled) | `AssembledInstalledPackage`, `GetInstalledPackageResponse`, `InstalledPackageAtEitherStage`, `ListInstalledPackagesResponse` |
9696
| [`package-lifecycle.zod.ts`](/docs/references/api/package-lifecycle) | `DiscardPackageDraftsResponse`, `DuplicatePackageResponse`, `EnsureCustomizationPackageRequest`, `EnsureCustomizationPackageResponse`, `GetPackageCustomizationsRequest`, `GetPackageCustomizationsResponse`, `ImportUnmanagedPackageRequest`, `ImportUnmanagedPackageResponse`, `ListPackageCommitsResponse`, `PackageExportBundle`, `PackageExportManifest`, `PackagePublishResult`, `ReassignOrphanedMetadataResponse`, `RevertPackageCommitResponse`, `RollbackToPackageCommitResponse` |
9797
| [`plugin-rest-api.zod.ts`](/docs/references/api/plugin-rest-api) | `ErrorHandlingConfig`, `OpenApiGenerationConfig`, `RequestValidationConfig`, `ResponseEnvelopeConfig`, `RestApiEndpoint`, `RestApiPluginConfig`, `RestApiRouteCategory`, `RestApiRouteRegistration`, `ValidationMode` |
98-
| [`protocol.zod.ts`](/docs/references/api/protocol) | `AiAgentCapabilities`, `AiAgentChatRequest`, `AiAgentSummary`, `AiAgentsResponse`, `AiChatRequest`, `AiChatResponse`, `AiCompleteRequest`, `AiConversation`, `AiConversationMessage`, `AiMessage`, `AiModelsResponse`, `AiPendingAction`, `AiPendingActionStatus`, `AiStreamChunk`, `ApproveAiPendingActionResponse`, `AuditMetaItemRequest`, `AuditMetaItemResponse`, `AutomationActionsResponse`, `AutomationTriggerRequest`, `AutomationTriggerResponse`, `BatchDataRequest`, `BatchDataResponse`, `BuildProbeReport`, `CheckPermissionRequest`, `CheckPermissionResponse`, `CloneDataResponse`, `CreateAiConversationRequest`, `CreateDataRequest`, `CreateDataResponse`, `CreateManyDataRequest`, `CreateManyDataResponse`, `DeleteDataRequest`, `DeleteDataResponse`, `DeleteManyDataRequest`, `DeleteManyDataResponse`, `DeleteMetaItemRequest`, `DeleteMetaItemResponse`, `DiffMetaItemRequest`, `DiffMetaItemResponse`, `DisablePackageRequest`, `DisablePackageResponse`, `EnablePackageRequest`, `EnablePackageResponse`, `FindDataRequest`, `FindDataResponse`, `FindReferencesToMetaResponse`, `FlowRegistration`, `FlowRegistrationRefusal`, `GetDataRequest`, `GetDataResponse`, `GetDiscoveryRequest`, `GetDiscoveryResponse`, `GetEffectivePermissionsRequest`, `GetEffectivePermissionsResponse`, `GetFieldLabelsRequest`, `GetFieldLabelsResponse`, `GetLocalesRequest`, `GetLocalesResponse`, `GetMetaDiagnosticsResponse`, `GetMetaItemCachedRequest`, `GetMetaItemCachedResponse`, `GetMetaItemLayeredRequest`, `GetMetaItemLayeredResponse`, `GetMetaItemRequest`, `GetMetaItemResponse`, `GetMetaItemsRequest`, `GetMetaItemsResponse`, `GetMetaTypesRequest`, `GetMetaTypesResponse`, `GetNotificationPreferencesRequest`, `GetNotificationPreferencesResponse`, `GetObjectPermissionsRequest`, `GetObjectPermissionsResponse`, `GetPackageRequest`, `GetPackageResponse`, `GetPresenceRequest`, `GetPresenceResponse`, `GetPublishedMetaItemResponse`, `GetRecordFieldAccessResponse`, `GetTranslationsRequest`, `GetTranslationsResponse`, `GetUiViewRequest`, `GetUiViewResponse`, `HistoryMetaItemRequest`, `HistoryMetaItemResponse`, `HttpFindQueryParams`, `InstallPackageRequest`, `InstallPackageResponse`, `ListAiConversationsRequest`, `ListAiConversationsResponse`, `ListAiPendingActionsRequest`, `ListAiPendingActionsResponse`, `ListDraftsResponse`, `ListNotificationsRequest`, `ListNotificationsResponse`, `ListPackagesRequest`, `ListPackagesResponse`, `MarkAllNotificationsReadRequest`, `MarkAllNotificationsReadResponse`, `MarkNotificationsReadRequest`, `MarkNotificationsReadResponse`, `MetadataAuthoringClient`, `MetadataAuthoringSurface`, `MetadataConflictError`, `Notification`, `NotificationPreferences`, `PublicFormSubmitResponse`, `PublishMetaItemRequest`, `PublishMetaItemResponse`, `PublishPackageDraftsRequest`, `PublishPackageDraftsResponse`, `RealtimeConnectRequest`, `RealtimeConnectResponse`, `RealtimeDisconnectRequest`, `RealtimeDisconnectResponse`, `RealtimeSubscribeRequest`, `RealtimeSubscribeResponse`, `RealtimeUnsubscribeRequest`, `RealtimeUnsubscribeResponse`, `RegisterDeviceRequest`, `RegisterDeviceResponse`, `RejectAiPendingActionResponse`, `RollbackMetaItemRequest`, `RollbackMetaItemResponse`, `RuntimeAuthoringIssue`, `RuntimeBuildIssue`, `SaveMetaItemRequest`, `SaveMetaItemResponse`, `SearchAllHit`, `SearchAllPageHit`, `SearchAllResponse`, `SeedAppliedIdList`, `SeedAppliedLanded`, `SetPresenceRequest`, `SetPresenceResponse`, `UninstallPackageRequest`, `UninstallPackageResponse`, `UnregisterDeviceRequest`, `UnregisterDeviceResponse`, `UpdateAiConversationRequest`, `UpdateDataRequest`, `UpdateDataResponse`, `UpdateManyDataRequest`, `UpdateManyDataResponse`, `UpdateNotificationPreferencesRequest`, `UpdateNotificationPreferencesResponse`, `ValidateDataIssue`, `ValidateDataRequest`, `ValidateDataResponse` |
98+
| [`protocol.zod.ts`](/docs/references/api/protocol) | `AiAgentCapabilities`, `AiAgentChatRequest`, `AiAgentSummary`, `AiAgentsResponse`, `AiChatRequest`, `AiChatResponse`, `AiCompleteRequest`, `AiConversation`, `AiConversationMessage`, `AiMessage`, `AiModelsResponse`, `AiPendingAction`, `AiPendingActionStatus`, `AiStreamChunk`, `ApproveAiPendingActionResponse`, `AuditMetaItemRequest`, `AuditMetaItemResponse`, `AutomationActionsResponse`, `AutomationTriggerRequest`, `AutomationTriggerResponse`, `BatchDataRequest`, `BatchDataResponse`, `BuildProbeReport`, `CheckPermissionRequest`, `CheckPermissionResponse`, `CloneDataResponse`, `CreateAiConversationRequest`, `CreateDataRequest`, `CreateDataResponse`, `CreateManyDataRequest`, `CreateManyDataResponse`, `DeleteDataRequest`, `DeleteDataResponse`, `DeleteManyDataRequest`, `DeleteManyDataResponse`, `DeleteMetaItemRequest`, `DeleteMetaItemResponse`, `DestructiveChangeIssue`, `DiffMetaItemRequest`, `DiffMetaItemResponse`, `DisablePackageRequest`, `DisablePackageResponse`, `EnablePackageRequest`, `EnablePackageResponse`, `FieldStillShownBy`, `FindDataRequest`, `FindDataResponse`, `FindReferencesToMetaResponse`, `FlowRegistration`, `FlowRegistrationRefusal`, `GetDataRequest`, `GetDataResponse`, `GetDiscoveryRequest`, `GetDiscoveryResponse`, `GetEffectivePermissionsRequest`, `GetEffectivePermissionsResponse`, `GetFieldLabelsRequest`, `GetFieldLabelsResponse`, `GetLocalesRequest`, `GetLocalesResponse`, `GetMetaDiagnosticsResponse`, `GetMetaItemCachedRequest`, `GetMetaItemCachedResponse`, `GetMetaItemLayeredRequest`, `GetMetaItemLayeredResponse`, `GetMetaItemRequest`, `GetMetaItemResponse`, `GetMetaItemsRequest`, `GetMetaItemsResponse`, `GetMetaTypesRequest`, `GetMetaTypesResponse`, `GetNotificationPreferencesRequest`, `GetNotificationPreferencesResponse`, `GetObjectPermissionsRequest`, `GetObjectPermissionsResponse`, `GetPackageRequest`, `GetPackageResponse`, `GetPresenceRequest`, `GetPresenceResponse`, `GetPublishedMetaItemResponse`, `GetRecordFieldAccessResponse`, `GetTranslationsRequest`, `GetTranslationsResponse`, `GetUiViewRequest`, `GetUiViewResponse`, `HistoryMetaItemRequest`, `HistoryMetaItemResponse`, `HttpFindQueryParams`, `InstallPackageRequest`, `InstallPackageResponse`, `ListAiConversationsRequest`, `ListAiConversationsResponse`, `ListAiPendingActionsRequest`, `ListAiPendingActionsResponse`, `ListDraftsResponse`, `ListNotificationsRequest`, `ListNotificationsResponse`, `ListPackagesRequest`, `ListPackagesResponse`, `MarkAllNotificationsReadRequest`, `MarkAllNotificationsReadResponse`, `MarkNotificationsReadRequest`, `MarkNotificationsReadResponse`, `MetadataAuthoringClient`, `MetadataAuthoringSurface`, `MetadataConflictError`, `Notification`, `NotificationPreferences`, `PublicFormSubmitResponse`, `PublishMetaItemRequest`, `PublishMetaItemResponse`, `PublishPackageDraftsRequest`, `PublishPackageDraftsResponse`, `RealtimeConnectRequest`, `RealtimeConnectResponse`, `RealtimeDisconnectRequest`, `RealtimeDisconnectResponse`, `RealtimeSubscribeRequest`, `RealtimeSubscribeResponse`, `RealtimeUnsubscribeRequest`, `RealtimeUnsubscribeResponse`, `RegisterDeviceRequest`, `RegisterDeviceResponse`, `RejectAiPendingActionResponse`, `RollbackMetaItemRequest`, `RollbackMetaItemResponse`, `RuntimeAuthoringIssue`, `RuntimeBuildIssue`, `SaveMetaItemRequest`, `SaveMetaItemResponse`, `SearchAllHit`, `SearchAllPageHit`, `SearchAllResponse`, `SeedAppliedIdList`, `SeedAppliedLanded`, `SetPresenceRequest`, `SetPresenceResponse`, `UninstallPackageRequest`, `UninstallPackageResponse`, `UnregisterDeviceRequest`, `UnregisterDeviceResponse`, `UpdateAiConversationRequest`, `UpdateDataRequest`, `UpdateDataResponse`, `UpdateManyDataRequest`, `UpdateManyDataResponse`, `UpdateNotificationPreferencesRequest`, `UpdateNotificationPreferencesResponse`, `ValidateDataIssue`, `ValidateDataRequest`, `ValidateDataResponse` |
9999
| [`push-delivery.zod.ts`](/docs/references/api/push-delivery) | `PushDeliveryData`, `PushRoute` |
100100
| [`push-relay.zod.ts`](/docs/references/api/push-relay) | `PushRelayDelivery`, `PushRelayError`, `PushRelayErrorResponse`, `PushRelayPayload`, `PushRelayPriority`, `PushRelayRequest`, `PushRelayResponse`, `PushRelayResult`, `PushRelayResultStatus` |
101101
| [`query-adapter.zod.ts`](/docs/references/api/query-adapter) | `ODataQueryAdapter`, `OperatorMapping`, `QueryAdapterConfig`, `QueryAdapterTarget`, `RestQueryAdapter` |

‎docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate.
1919

2020
| Dir | Sites |
2121
|---|---|
22-
| `api/` | 531 |
22+
| `api/` | 533 |
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The object save path reaches `@objectstack/lint` only through
5+
* `@objectstack/lint/runtime`, never through the package ROOT (#4463;
6+
* `packages/lint/src/runtime.ts`). `destructive-still-shown-by.ts` needs three
7+
* judges only the root exports, so it loads the root lazily with a dynamic
8+
* `import()`, as `build-probes.ts` does.
9+
*
10+
* Pinned over the STATIC import closure of `protocol-save.ts`: every module it
11+
* reaches through a relative `import … from` / `export … from`, none of which
12+
* may import the lint root as a value. A type-only import is erased and allowed;
13+
* a dynamic `import('@objectstack/lint')` is the sanctioned shape.
14+
*/
15+
16+
import { describe, expect, it } from 'vitest';
17+
import { existsSync, readFileSync } from 'node:fs';
18+
import { dirname, join, resolve } from 'node:path';
19+
import { fileURLToPath } from 'node:url';
20+
21+
const SRC = dirname(fileURLToPath(import.meta.url));
22+
23+
/** A static value import or re-export of the lint ROOT (not `/runtime`, not `import type`). */
24+
const STATIC_LINT_ROOT = /^\s*(?:import|export)\s+(?!type\b)[^;]*?\bfrom\s+['"]@objectstack\/lint['"]/m;
25+
/** Static relative imports and re-exports, the edges of the closure. */
26+
const RELATIVE_EDGE = /^\s*(?:import|export)\s+(?!type\b)[^;]*?\bfrom\s+['"](\.{1,2}\/[^'"]+)['"]/gm;
27+
28+
function closureOf(entry: string): string[] {
29+
const seen = new Set<string>();
30+
const queue = [resolve(SRC, entry)];
31+
while (queue.length > 0) {
32+
const file = queue.shift() as string;
33+
if (seen.has(file)) continue;
34+
seen.add(file);
35+
const text = readFileSync(file, 'utf8');
36+
for (const m of text.matchAll(RELATIVE_EDGE)) {
37+
const target = join(dirname(file), m[1].replace(/\.js$/, '.ts'));
38+
if (existsSync(target)) queue.push(target);
39+
}
40+
}
41+
return [...seen];
42+
}
43+
44+
describe('the object save path does not statically import the lint root', () => {
45+
it('no module in protocol-save.ts\'s static closure imports @objectstack/lint as a value', () => {
46+
const closure = closureOf('protocol-save.ts');
47+
// Not vacuous: the walk reached the module that needs the judges.
48+
expect(closure).toContain(join(SRC, 'destructive-still-shown-by.ts'));
49+
const offenders = closure.filter((f) => STATIC_LINT_ROOT.test(readFileSync(f, 'utf8')));
50+
expect(offenders).toEqual([]);
51+
});
52+
53+
it('the still-shown-by module loads the judges through a dynamic import of the root', () => {
54+
const text = readFileSync(join(SRC, 'destructive-still-shown-by.ts'), 'utf8');
55+
expect(text).toMatch(/await import\(['"]@objectstack\/lint['"]\)/);
56+
// The detector itself bites on the shape it forbids.
57+
expect(STATIC_LINT_ROOT.test("import { validateFormLayout } from '@objectstack/lint';")).toBe(true);
58+
expect(STATIC_LINT_ROOT.test("import type { X } from '@objectstack/lint';")).toBe(false);
59+
expect(STATIC_LINT_ROOT.test("import { runRuntimeAuthoringRules } from '@objectstack/lint/runtime';")).toBe(false);
60+
});
61+
});

0 commit comments

Comments
 (0)