Skip to content

refactor(types,core)!: retire the inert validation action-param key (#3201) - #3283

Merged
xuyushun441-sys merged 1 commit into
mainfrom
claude/issue-3201-retire-actionparam-validation
Aug 3, 2026
Merged

refactor(types,core)!: retire the inert validation action-param key (#3201)#3283
xuyushun441-sys merged 1 commit into
mainfrom
claude/issue-3201-retire-actionparam-validation

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Fixes#3201

按 PM 裁定走选项 1(移除),不新增 spec 能力(选项 2 已否决,未触碰 packages/spec)。

问题

validation?: string 同时声明在 action-param 契约的两半上,两边都没人读,而服务端直接拒收:

  • 作者侧 —— @object-ui/typesActionParam(packages/types/src/ui-action.ts)
  • 解析后 —— @object-ui/coreActionParamDef(packages/core/src/actions/ActionRunner.ts)

@objectstack/spec/uiActionParamSchema.strict()ACTION_PARAM_KEYS 不含它,所以作者写下它就是一次硬解析拒绝,而 tsc 对着公共类型却照单全收。本 PR 实测确认:

parse { name, label, validation } success? false
ERROR: code "unrecognized_keys", keys ["validation"],
message "Unrecognized key(s) on this action param: `validation`. …"
parse without validation success? true

这正是「类型说合法、运行时当场拒收」的 ADR-0049 enforce-or-remove 目标形态。

resolved 侧确实无消费者(逐一核实)

单子的判断成立,并且比单子说的还要彻底:

  • RawActionParam(resolveActionParams.ts)根本没有validation 这个键;
  • RuntimeField没有validation,所以 field-backed param 从来无从继承;
  • paramToField() / ActionParamDialog(app-shell 与 components 两处)/ paramValueShape.ts / useConsoleActionRuntime.tsx / MetadataTypeActions.tsx —— 全部 grep -c validation0;
  • 仓内唯一的 def.validation 读取在 packages/plugin-detail/src/RecordDetailDrawer.tsx:252,读的是 schemaFields[name] 这个对象字段 schema,与 action param 无关。

一处顺带纠正:resolveActionParams.ts 模块注释原先声称 field-backed param 会从字段继承 validation —— 这是错的(RuntimeField 上没有该键)。仅改注释,无逻辑改动;留着它会在移除之后继续教错同一件事。

漂移守卫回到「无例外」

packages/types/src/__tests__/page-nav-misc-spec-parity.test.ts 原先把 validation 作为唯一具名例外携带,其注释自己预言过「retired 那天这行会编译失败,例外应被删除而不是被继承」—— 现在正是那天。

新断言不再有任何例外:

typeNoLocalOnlyKeys=[LocalOnlyParamKey]extends[never] ? true : false;

刻意用 [ T ] extends [ never ]元组包裹形式,而非裸的 T extends never:裸形式会分配(distribute),对空联合求值得到 never 而非 true,恰好在断言开始被满足的那一刻编译失败。另加一条 @ts-expect-error 钉死「作者写 validation 现在就是 tsc 错误」。

type 不构成例外:它是对 spec 已声明键的收窄(ResolvableParamFieldType),不是新增键。

Sabotage 验证(守卫必须能红)

A —— 任意新增本地键(sabotageOnlyKey?: string):

src/__tests__/page-nav-misc-spec-parity.test.ts(389,11): error TS2322: Type 'true' is not assignable to type 'false'.
Exit status 2

B —— 把 validation 原样加回,两条断言同时红:

src/__tests__/page-nav-misc-spec-parity.test.ts(389,11): error TS2322: Type 'true' is not assignable to type 'false'.
src/__tests__/page-nav-misc-spec-parity.test.ts(404,5): error TS2578: Unused '@ts-expect-error' directive.
REAL EXIT CODE: 2

还原后 REAL EXIT CODE: 0

注意守卫的真实执行者是 tsc -p tsconfig.test.json(packages/typestype-check 第三趟)—— 包自身的 tsconfig.json**/*.test.ts 排除在外,build 不覆盖测试文件,vitest 也不评估 @ts-expect-error

验证

  • pnpm --filter @object-ui/types --filter @object-ui/core type-check → 退出码 0(types 三趟全过,含 tsconfig.test.json)
  • pnpm exec vitest run packages/types packages/core/src/actions packages/app-shell/src/utils --maxWorkers=255 文件 / 914 用例全绿,退出码 0
  • node scripts/check-changeset-no-major.mjs✅ No changeset declares a 'major' bump.
  • eslint 四个改动文件 → 0 errors,warning 数与 origin/main 基线持平(未新增)
  • 以上均在 rebase 到最新 origin/main(含 fix(console): un-invert the validation sample's condition and drop 4 silently-stripped keys #3282)之后重跑过

Changeset

两个已发布类型移除键,按仓库版本策略标 minor(不是 major —— fixed 组任一 major 会把 39 个包推离 @objectstack 的节奏),正文写清 FROM → TO 与迁移指引:若你声明过 validation,它从未生效且会被服务端拒收,删掉即可


🤖 Generated with Claude Code

https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa


Generated by Claude Code

…#3201)
`validation?: string` was declared on BOTH halves of the action-param
contract — the authoring `ActionParam` (`@object-ui/types`) and the
resolved `ActionParamDef` (`@object-ui/core`) — read by neither, and
rejected outright by the server.
`ActionParamSchema` in `@objectstack/spec/ui` is `.strict()` and does not
list `validation`, so an authored key is a hard parse rejection
("Unrecognized key(s) on this action param: `validation`") while `tsc`
against the public type accepted it happily. Verified there is no
consumer on the resolved side either: it was never a key of
`resolveActionParams()`'s `RawActionParam`, `RuntimeField` has no
`validation` for a field-backed param to inherit, and `paramToField()`
never mapped it, so it could not reach the field widgets — whose rules
`buildValidationRules()` builds from `required` / `minLength` /
`maxLength` / `pattern`.
Removed rather than implemented, on ADR-0049 enforce-or-remove: giving it
meaning would mean first deciding what an "expression" is here (CEL?
formula? regex?) and adding it to `@objectstack/spec`, which is where such
a capability has to start.
This retires the last named exception in #3174's drift guard, which
carried `validation` as the one key `ActionParam` added on top of the
spec's set. The rule it pins — the authoring type declares exactly the
spec's authorable keys — is now literal: the guard asserts the local-only
key set is empty (`[LocalOnlyParamKey] extends [never]`, tuple-wrapped to
defeat distribution over the empty union) plus a `@ts-expect-error` on an
authored `validation`. Sabotage-verified: re-adding `validation`, or any
other undeclared local key, fails `tsc -p tsconfig.test.json`.
Also corrects a stale line in `resolveActionParams.ts`'s module comment
that claimed field-backed params inherit `validation` from the object
field — they never did; there is no such key on `RuntimeField`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa
@vercel

vercelBot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectuiIgnoredIgnoredAug 3, 2026 10:33am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

MetricValueBudget
Main entry (gzip)28.1 KB350 KB
Entry fileindex-jMXoCnx9.js
StatusPASS

📦 Bundle Size Report

PackageSizeGzipped
app-shell (index.js)8.47KB3.09KB
app-shell (runtime-config.js)7.42KB2.32KB
app-shell (types.js)0.01KB0.04KB
app-shell (urlParams.js)7.57KB2.97KB
auth (AuthContext.js)0.31KB0.24KB
auth (AuthGuard.js)1.17KB0.53KB
auth (AuthProvider.js)22.10KB4.37KB
auth (AuthShell.js)3.49KB1.40KB
auth (ForgotPasswordForm.js)12.12KB3.41KB
auth (LoginForm.js)17.86KB5.29KB
auth (PreviewBanner.js)0.90KB0.50KB
auth (RegisterForm.js)6.43KB2.09KB
auth (SocialSignInButtons.js)9.60KB3.89KB
auth (UserMenu.js)3.40KB1.22KB
auth (auth-gate-events.js)1.29KB0.66KB
auth (authStyles.js)5.04KB1.72KB
auth (createAuthClient.js)35.76KB9.11KB
auth (createAuthenticatedFetch.js)4.37KB1.69KB
auth (index.js)2.35KB1.07KB
auth (org-roles.js)6.66KB2.78KB
auth (phone-identifier.js)1.11KB0.66KB
auth (types.js)0.59KB0.35KB
auth (useAuth.js)4.91KB0.87KB
auth (useIsWorkspaceAdmin.js)1.61KB0.85KB
collaboration (CommentThread.js)18.38KB4.49KB
collaboration (LiveCursors.js)3.17KB1.27KB
collaboration (PresenceAvatars.js)3.65KB1.42KB
collaboration (PresenceProvider.js)2.79KB1.13KB
collaboration (index.js)1.25KB0.53KB
collaboration (useCommentSearch.js)1.98KB0.88KB
collaboration (useConflictResolution.js)7.75KB1.86KB
collaboration (useMentionNotifications.js)1.81KB0.68KB
collaboration (usePresence.js)6.33KB1.84KB
collaboration (useRealtimeSubscription.js)7.91KB2.01KB
components (index.js)476.42KB104.61KB
core (index.js)2.25KB0.80KB
create-plugin (index.js)9.28KB2.98KB
data-objectstack (index.js)136.23KB34.75KB
fields (index.js)223.53KB54.78KB
i18n (LocalizationContext.js)1.76KB0.96KB
i18n (currency.js)1.22KB0.64KB
i18n (i18n.js)4.32KB1.77KB
i18n (index.js)2.46KB0.96KB
i18n (pickLocalized.js)1.70KB0.83KB
i18n (provider.js)5.37KB1.72KB
i18n (useObjectLabel.js)26.14KB6.07KB
i18n (useSafeTranslation.js)3.26KB1.44KB
layout (index.js)37.96KB10.54KB
mobile (MobileProvider.js)0.92KB0.49KB
mobile (ResponsiveContainer.js)0.94KB0.38KB
mobile (breakpoints.js)1.51KB0.70KB
mobile (createOfflineDataSource.js)5.61KB1.74KB
mobile (index.js)1.50KB0.62KB
mobile (offlineQueue.js)3.91KB1.35KB
mobile (pwa.js)0.97KB0.49KB
mobile (serviceWorker.js)1.48KB0.62KB
mobile (serviceWorkerSource.js)3.41KB1.48KB
mobile (useBreakpoint.js)1.54KB0.65KB
mobile (useGesture.js)6.96KB1.98KB
mobile (useOfflineSync.js)1.99KB0.72KB
mobile (usePullToRefresh.js)2.53KB0.85KB
mobile (useResponsive.js)0.71KB0.42KB
mobile (useResponsiveConfig.js)1.36KB0.63KB
mobile (useSpecGesture.js)4.05KB1.53KB
mobile (useTouchTarget.js)1.01KB0.54KB
permissions (MePermissionsProvider.js)8.75KB3.06KB
permissions (PermissionContext.js)0.31KB0.25KB
permissions (PermissionGuard.js)0.89KB0.45KB
permissions (PermissionProvider.js)3.67KB1.12KB
permissions (evaluator.js)4.41KB1.44KB
permissions (index.js)0.91KB0.41KB
permissions (store.js)0.91KB0.42KB
permissions (useFieldPermissions.js)1.28KB0.52KB
permissions (usePermissions.js)1.55KB0.71KB
plugin-ai (index.js)15.71KB3.79KB
plugin-calendar (index.js)44.98KB12.37KB
plugin-charts (index.js)60.54KB17.13KB
plugin-chatbot (index.js)180.09KB42.72KB
plugin-dashboard (index.js)112.01KB28.86KB
plugin-designer (index.js)210.51KB42.51KB
plugin-detail (index.js)230.56KB56.80KB
plugin-editor (index.js)2.46KB1.10KB
plugin-form (index.js)111.49KB26.95KB
plugin-gantt (index.js)162.25KB39.55KB
plugin-grid (index.js)185.08KB49.04KB
plugin-kanban (index.js)47.89KB13.18KB
plugin-list (index.js)104.94KB25.32KB
plugin-map (index.js)16.81KB5.24KB
plugin-markdown (index.js)13.72KB4.69KB
plugin-report (index.js)40.55KB10.59KB
plugin-timeline (index.js)25.76KB7.33KB
plugin-tree (index.js)8.34KB2.82KB
plugin-view (index.js)83.67KB20.43KB
providers (DataSourceProvider.js)0.75KB0.39KB
providers (MetadataProvider.js)1.37KB0.59KB
providers (ThemeProvider.js)1.90KB0.85KB
providers (UploadProvider.js)11.71KB3.53KB
providers (index.js)0.44KB0.22KB
providers (types.js)0.01KB0.04KB
react-runtime (index.js)5.67KB2.37KB
react (LazyPluginLoader.js)3.77KB1.33KB
react (SchemaRenderer.js)19.28KB6.38KB
react (data-invalidation.js)5.05KB2.08KB
react (index.js)1.02KB0.55KB
react (spec-input.js)0.20KB0.18KB
sdui-parser (codegen.js)4.09KB1.74KB
sdui-parser (index.js)4.47KB2.03KB
sdui-parser (parse.js)10.04KB2.82KB
sdui-parser (types.js)0.29KB0.24KB
sdui-parser (validate.js)4.69KB1.48KB
types (ai.js)0.20KB0.17KB
types (api-types.js)0.20KB0.18KB
types (app.js)2.87KB0.99KB
types (base.js)0.20KB0.18KB
types (blocks.js)0.20KB0.18KB
types (complex.js)0.20KB0.18KB
types (crud.js)0.20KB0.18KB
types (data-display.js)0.20KB0.18KB
types (data-protocol.js)0.20KB0.19KB
types (data.js)0.20KB0.18KB
types (designer.js)1.87KB0.85KB
types (disclosure.js)0.20KB0.18KB
types (error-code.js)1.54KB0.88KB
types (feedback.js)0.20KB0.18KB
types (field-types.js)0.20KB0.18KB
types (form.js)0.20KB0.18KB
types (http-retry.js)4.32KB2.02KB
types (index.js)2.46KB1.21KB
types (layout.js)0.20KB0.18KB
types (managed-by.js)0.19KB0.18KB
types (mobile.js)0.20KB0.18KB
types (navigation.js)0.20KB0.18KB
types (objectql.js)0.20KB0.18KB
types (overlay.js)0.20KB0.18KB
types (permissions.js)0.20KB0.18KB
types (plugin-scope.js)0.20KB0.18KB
types (record-components.js)0.20KB0.19KB
types (record-semantics.js)1.28KB0.67KB
types (registry.js)0.20KB0.18KB
types (reports.js)0.20KB0.18KB
types (spec-report.js)5.05KB1.93KB
types (system-fields.js)3.33KB1.54KB
types (theme.js)0.20KB0.18KB
types (ui-action.js)3.40KB1.71KB
types (views.js)0.20KB0.18KB
types (widget.js)0.20KB0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@xuyushun441-sys
xuyushun441-sys marked this pull request as ready for review August 3, 2026 10:42
@xuyushun441-sys
xuyushun441-sys added this pull request to the merge queueAug 3, 2026
Merged via the queue into main with commit f833d3aAug 3, 2026
17 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the claude/issue-3201-retire-actionparam-validation branch August 3, 2026 10:43
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActionParam.validation / ActionParamDef.validation is declared, never read, and rejected by the spec parser

2 participants

@xuyushun441-sys@claude