Skip to content

build(types): type-check this package's tests, so the spec-derivation guards actually run (objectstack#4074) - #3009

Merged
os-zhuang merged 1 commit into
mainfrom
claude/quirky-euler-p9dsfm
Jul 30, 2026
Merged

build(types): type-check this package's tests, so the spec-derivation guards actually run (objectstack#4074)#3009
os-zhuang merged 1 commit into
mainfrom
claude/quirky-euler-p9dsfm

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Follow-up to #3003. While correcting a comment there I measured something worth its own change: spec-derived-unions.test.ts — the file that exists to stop a spec-derived union from being re-forked into a hand-written copy — was not being compiled by anything.

Measured, not assumed

Its header claimed the satisfies checks in it "are the real enforcement". Reverting ActionParamFieldType from the spec's FieldType back to a hand-written subset:

before this PRafter
tsc output0 errorsTS1360 on the satisfies line

tsconfig.json excludes test files — correctly, since it is the package build (rootDir / composite / declaration), so tests would emit into dist — and no other tsc invocation read them. There is no vitest typecheck project either.

The sibling guards over ChartType, ReportType, ActionType and PageType were inert for the same reason, so the anti-regression mechanism left behind by #2944 / #2901 was not running in CI. Those forks were each already drifted once when they were found; nothing would have caught a second drift.

The fix

packages/types/tsconfig.test.json, chained from the package's type-check script — the shape this package already uses for tsconfig.examples.json: a separate, emit-free project.

Kept separate rather than deleting the exclude, for a reason that matters: the reexport guard scans sibling sources off disk, so it needs types: ["node"]. Folding that into tsconfig.json would let package source reference Node APIs and still compile, in a package that ships to browsers.

The 39 pre-existing errors it surfaced

p2-spec-exports.test.ts — 22. It imported eight …Schema names as types from ../index. #2561 decision (a) removed exactly those, and the sibling spec-ui-schema-reexports.test.tsasserts their absence — so this file contradicted its own guard for the whole interval. A type-only import of a nonexistent name erases at runtime, so the suite stayed green.

Its fixtures were also typed as parsed output while being parse input — these schemas .default() several fields, so { enabled: true } is valid input but the output type requires them. They now use z.input<>, the distinction spec draws itself with ActionInput. Same story for operator: 'eq': a legacy alias spec folds at parse time, valid as input and absent from the canonical output union. The value-type re-exports this file exists to pin are now asserted explicitly, instead of incidentally through fixture annotations.

app-creation-types.test.ts / system-fields.test.ts — 3. They imported the package by its own name. turbo's type-check task is dependsOn: ["^build"] (upstream only), so the package's own dist does not exist when it runs. They now use the relative import all 13 sibling tests use.

p1-spec-alignment.test.ts — 14, declared as debt rather than fixed. Excluded in tsconfig.test.json with a written reason, because these are not hygiene. Every one sits in a test named should accept <shape> whose entire purpose is asserting the type accepts that shape — and the type rejects it:

it('should accept sharing in ObjectUI format { visibility, enabled }',()=>{constschema: ListViewSchema={,sharing: {visibility: 'team',enabled: true}};expect(schema.sharing?.visibility).toBe('team');// can only pass: it asserts a JS});// object literal kept the key just written

ListViewSchema.sharing is { type, lockedBy }. The legacy shape is real and is handled — foldSharing in core's normalize-list-view.ts folds visibility / enabled into the spec's ViewSharing.type — but only as untyped input (normalizeListViewSchema<T>(schema: T): T), so no type names it. That is the same "implementation wider than the type" shape as execute (objectstack#3856), navigation (#2944) and the param aliases (#3003).

Each of the 8 sites is a separate decision — widen the type so the claim becomes true, or drop the claim — and several touch the public surface. Rewriting them silently while landing the plumbing would bury the finding, so they are tracked on objectstack#4074.

Scope

Deliberately narrow: only packages/types, where the spec-derivation guards live. 28 other packages still exclude their tests; 5 (fields, cli, data-objectstack, plugin-charts, plugin-editor) already include them, so this establishes a pattern that is already load-bearing elsewhere rather than sweeping the repo.

This also corrects an overstatement in #3003, which said every package tsconfig excludes tests. It is 33 of 41.

Verification

  • Discrimination check — the point of the PR: revert the derived alias, get TS1360. Zero errors before.
  • pnpm type-check76/76 tasks.
  • pnpm vitest run717 files / 8380 tests passed, 1 file / 24 skipped.
  • packages/types: all three tsconfig projects clean; 16 files / 246 tests.
  • eslint packages/types/src — 0 errors (249 pre-existing any warnings, none from this diff).
  • node scripts/check-changeset-fixed.mjs — clean.

Changeset is patch: no public API changes, only build config and tests.

Refs objectstack#4074, #3003, #2561, #2944, #2901, #2911


Generated by Claude Code

…guards actually run (objectstack#4074)
`spec-derived-unions.test.ts` exists to stop a spec-derived union from being
re-forked into a hand-written copy, and its header claimed the `satisfies` checks
in it "are the real enforcement". They were not. `tsconfig.json` excludes test
files — correctly, since it is the package build with `rootDir` / `composite` /
`declaration`, so tests would emit into dist — and no other `tsc` invocation read
them.
Measured, not assumed: reverting `ActionParamFieldType` from the spec's
`FieldType` back to a hand-written subset produced ZERO type errors before this
change, and now produces TS1360 on the `satisfies` line. The sibling guards over
`ChartType`, `ReportType`, `ActionType` and `PageType` were equally inert, so the
anti-regression mechanism left by #2944/#2901 was not running in CI.
`tsconfig.test.json` follows the shape this package already uses for
`tsconfig.examples.json`: a separate, emit-free project chained from `type-check`.
Kept separate rather than deleting the exclude so the BUILD stays honest — the
reexport guard's source scan needs `types: ["node"]`, and folding that into
`tsconfig.json` would let package SOURCE reference Node APIs and still compile,
in a package that ships to browsers.
Turning it on surfaced 39 pre-existing errors in test files. Fixed:
- `p2-spec-exports.test.ts` imported eight `…Schema` names as types from
`../index`. #2561 decision (a) removed those and the sibling
`spec-ui-schema-reexports.test.ts` asserts their absence, so this file
contradicted its own guard for the whole interval — a type-only import of a
nonexistent name erases at runtime, so the suite stayed green. Its minimal
fixtures were also typed as parsed OUTPUT while being parse INPUT (these
schemas `.default()` several fields); they use `z.input<>` now, the distinction
spec draws itself with `ActionInput`. `operator: 'eq'` is a legacy alias spec
folds at parse time — valid input, absent from the canonical output union. The
value-type re-exports the file exists to pin are now asserted explicitly
instead of implicitly through fixture annotations.
- `app-creation-types.test.ts` / `system-fields.test.ts` imported the package by
its own name; turbo's `type-check` dependsOn `^build` (upstream only), so the
package's own dist does not exist when it runs. They use the relative import
every sibling test uses.
Declared as debt rather than fixed: `p1-spec-alignment.test.ts` is excluded with
a written reason. Its 14 errors are not hygiene — every one sits in a test named
"should accept <shape>" whose whole purpose is asserting the type accepts that
shape, and the type rejects it. The clearest case, sharing as
`{ visibility, enabled }`, describes a shape that IS handled by `foldSharing` in
core's `normalize-list-view.ts`, but only as untyped input
(`normalizeListViewSchema<T>(schema: T): T`), so no type names it. Each site is a
separate decision — widen the type so the claim becomes true, or drop the claim —
and several touch the public surface, so rewriting them silently here would bury
the finding.
Scope is deliberately narrow: only `packages/types` is converted. 28 other
packages still exclude their tests, and 5 (`fields`, `cli`, `data-objectstack`,
`plugin-charts`, `plugin-editor`) already include them. This establishes the
pattern rather than sweeping the repo.
Refs objectstack#4074, #3003, #2561, #2944, #2901, #2911
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DBMo8gnFduzgpuSHd5Eje
@vercel

vercelBot commented Jul 30, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectuiIgnoredIgnoredJul 30, 2026 9:45am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

MetricValueBudget
Main entry (gzip)27.9 KB350 KB
Entry fileindex-B52fhQQg.js
StatusPASS

📦 Bundle Size Report

PackageSizeGzipped
app-shell (index.js)8.20KB2.97KB
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.25KB1.01KB
auth (org-roles.js)6.72KB2.85KB
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)456.06KB99.57KB
core (index.js)2.16KB0.78KB
create-plugin (index.js)9.28KB2.98KB
data-objectstack (index.js)134.67KB34.24KB
fields (index.js)222.07KB54.35KB
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)25.17KB5.80KB
i18n (useSafeTranslation.js)3.26KB1.44KB
layout (index.js)38.45KB10.67KB
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)6.84KB2.42KB
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.90KB12.35KB
plugin-charts (index.js)60.01KB16.96KB
plugin-chatbot (index.js)180.09KB42.72KB
plugin-dashboard (index.js)110.24KB28.47KB
plugin-designer (index.js)210.56KB42.56KB
plugin-detail (index.js)216.52KB53.02KB
plugin-editor (index.js)2.46KB1.10KB
plugin-form (index.js)104.48KB25.29KB
plugin-gantt (index.js)162.26KB39.53KB
plugin-grid (index.js)180.86KB47.45KB
plugin-kanban (index.js)47.82KB13.18KB
plugin-list (index.js)102.39KB24.18KB
plugin-map (index.js)16.80KB5.24KB
plugin-markdown (index.js)13.65KB4.67KB
plugin-report (index.js)40.32KB10.53KB
plugin-timeline (index.js)25.75KB7.32KB
plugin-tree (index.js)8.36KB2.81KB
plugin-view (index.js)85.88KB20.99KB
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
sdui-parser (codegen.js)4.09KB1.74KB
sdui-parser (index.js)3.47KB1.54KB
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)0.77KB0.41KB
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 (index.js)2.00KB0.96KB
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.04KB1.93KB
types (system-fields.js)2.39KB1.17KB
types (theme.js)0.20KB0.18KB
types (ui-action.js)1.08KB0.64KB
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

@os-zhuang
os-zhuang marked this pull request as ready for review July 30, 2026 10:18
@os-zhuang
os-zhuang merged commit a045a32 into mainJul 30, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/quirky-euler-p9dsfm branch July 30, 2026 10:18
os-zhuang added a commit that referenced this pull request Jul 30, 2026
… the spec's declaration forms, ListViewSchema stops promising phantom defaults (objectstack#4074) (#3020)
Three public types said something different from what the platform accepts,
found by making packages/types' tests compile (#3009) and resolving the
declared p1-spec-alignment.test.ts debt site-by-site.
ActionParam is now the AUTHORING shape, aligned with the spec's input:
name/label/type optional, field/objectOverride added. The spec's primary
declaration form — a bare field reference inheriting label/type/validation/
options from an object field — was unrepresentable while all three were
required. The RESOLVED shape the dialog consumes (after app-shell's
resolveActionParams() inlines the reference) remains core's ActionParamDef,
all three required: authoring and resolved are different types on purpose.
label is the spec's I18nLabel by import — which the new compile-time guard
promptly revealed to be aliased to plain string in the current spec, so no
behavioural widening today; importing the alias means objectui tracks any
future widening automatically.
ListViewInferred is z.input, not z.infer. The spec sub-schemas flowing into
the list-view surface (userActions, tabs→ViewTab, sharing) carry .default()s,
so the inferred output type made userActions.refresh or a tab's pinned/visible
REQUIRED — but nothing on the render path runs .parse(): normalizeListViewSchema
deliberately applies no defaults ("an absent flag stays absent", its own suite).
The output type rejected valid authored metadata while promising renderers
defaults that never arrive; input matches both author and runtime.
FormField.dependsOn is DependsOnInput. The runtime reader
(resolveCascadingOptions) has always accepted a bare name, a list of names, or
{field, param} entries; the public property said string, so array-authored
metadata type-errored while working and the form renderer read the key through
(f as any).dependsOn to get past its own type. The shape now lives in
@object-ui/types next to FormField; core imports and re-exports it; the two
as-any reads in components are typed.
The p1-spec-alignment.test.ts exclusion is gone — its 14 errors resolved:
the "sharing in ObjectUI format" and legacy-ARIA fixtures are re-seated as
normalizer-input dialects (folded by normalizeListViewSchema; asserted
branch-by-branch in core's normalize-list-view.test.ts, the seam where the
fold runs), and the one fixture no surface ever admitted (an ObjectQL triplet
as a spec ViewTab.filter) is corrected to the rule-object form. Every test
file in @object-ui/types is compiled, no exclusions.
Discrimination-checked: reverting ListViewInferred to z.infer, dependsOn to
string, or ActionParam.name to required each fails compile in the now-compiled
tests (TS2739 / TS2322 / TS2741); restored, all projects clean.
Claude-Session: https://claude.ai/code/session_014DBMo8gnFduzgpuSHd5Eje
Co-authored-by: Claude <noreply@anthropic.com>
os-zhuang added a commit that referenced this pull request Jul 31, 2026
…engine stops disagreeing with the server (#3103) (#3107)
Five rule types in `data-protocol.ts` were hand-written interfaces labelled
`(ObjectStack Spec v2.0.1)` while the installed spec was 17.0.0-rc.0. Nothing
bound them to the spec, so fifteen majors of drift accumulated with `tsc` silent
and the comment still vouching for it — the planted-premise failure class
objectstack#4115 was filed for.
They are now `z.input` derivations of the spec's schemas. `z.input`, not
`z.infer`: objectui consumes AUTHORED metadata off `/meta`, before the spec's
defaults and ExpressionInput canonicalization run, so `condition` really is
`string | {dialect, source}` and `active`/`events`/`priority` really can be
absent.
What the copies had drifted into, and what each cost the user — the engine is a
client PRE-CHECK of rules `objectql/src/validation/rule-validator.ts` enforces,
so every one of these is a disagreement with the authority:
- Predicate POLARITY was inverted. The server violates a rule when the
predicate is TRUE; the engine violated it when FALSE. Every spec-authored
`script`/`cross_field` rule got the opposite verdict.
- `conditional` read `condition` + `rules[]` where the spec says `when` +
`then`/`otherwise` → silent no-op, and `otherwise` never ran at all.
- `format` read `pattern` where the spec says `regex` → `undefined.test()`
threw into a catch that reported a VIOLATION, blocking writes the server
accepts.
- Envelope-valued conditions hit `expression.trim()`, threw, and read as
"passes" → silent no-op.
- An absent `active` disabled the rule; an absent `events` threw. Both arrive
absent because the spec defaults them at parse time.
- `initialStates` (objectstack#3165) and `priority` were missing entirely;
`events: 'delete'` was still advertised after objectstack#3184 retired it.
`unique`/`async`/`range` have no spec counterpart — the spec removed the first
two deliberately (uniqueness → a unique index, since SELECT-then-INSERT is racy;
async → the form layer) — and are now @deprecated, with a test proving the
spec's union rejects them, so the comment is load-bearing rather than decorative.
Gates, each mutation-tested: the compile-time pins in
`validation-rule-spec-parity.test.ts` (live because tsconfig.test.json compiles
it, #3009) go TS1360 when a derivation is reverted, and the engine suite goes red
for polarity, envelope coercion, `otherwise`, `initialStates` and the spec
defaults. `ConditionalValidation.then/otherwise` carry one pinned divergence —
the spec's published types erase them to `unknown` (objectstack#4171) — with an
inverted pin that fails the day upstream fixes it.
Canonicity now rides on the import and the gate, not the comment: `grep
"Spec v2.0.1" packages/types/src/data-protocol.ts` is empty, and objectstack#4115's
ledger drops 120 -> 115.
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
akarma-synetal pushed a commit to akarma-synetal/objectui that referenced this pull request Aug 3, 2026
…assertions (objectstack-ai#3181) (objectstack-ai#3187)
The file's `type _X = Assert<Equal<A, B>>` lines were never read by any
compiler. `packages/app-shell/tsconfig.json` is the BUILD config and excludes
`**/*.test.ts`; CI's only type gate drives that config (`pnpm type-check` ->
turbo -> per-package `tsc --noEmit`), eslint is not type-aware, and vitest
erases types before it runs. A provably-false `Assert<Equal<1, 2>>` appended to
the file passed `pnpm type-check` at exit 0 — the same "declared != enforced"
landmine the file's own header cites objectstack-ai#3009 for.
Adds `packages/app-shell/tsconfig.typetests.json`: an emit-free project with an
EXPLICIT include list (not a glob), chained from the package's `type-check`
script so it runs in the existing CI `Type Check` job. The list is explicit
because app-shell's wider test tree still has a pre-existing error backlog,
already declared as TEST_DEBT — a glob would sweep that in and the project would
get deleted rather than fixed. That backlog stays tracked in objectstack-ai#3181.
`scripts/check-type-check-coverage.mjs` grows the matching ratchet: a
`tsconfig.typetests.json` that `type-check` does not chain, that emits, or that
includes no test file is now a hard failure, so this gate cannot go quiet the
same way the assertions did.
Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
Co-authored-by: Claude <noreply@anthropic.com>
akarma-synetal pushed a commit to akarma-synetal/objectui that referenced this pull request Aug 10, 2026
…dy forwards (objectstack-ai#3309) (objectstack-ai#3772)
`BulkActionParam.options` 的 entry 之前是封闭的 `{ label, value }`,而这条路径上
其余三层都不同意它:
- 运行期 `bulkParamToField` 把每个 entry 整体 spread 进交给 widget 的 field
metadata(`{ ...o, value: String(o.value) }`),额外键全部存活;
- 目的地 `SelectOptionMetadata` 声明了 `color` / `icon` / `disabled` /
`visibleWhen`,`@object-ui/fields` 确实在读(`option?.color` 两处);
- `@objectstack/spec` 的 `BulkActionParamSchema` 已把同一个 entry 转成
`.passthrough()`(objectstack#4001,维护者裁决 A),服务端照收;
- 它自己的父级 `BulkActionParam` 一直有 `[key: string]: unknown` 兜底注释。
于是作者写 `options: [{ label, value, color: '#8B5CF6' }]` 会拿到一个
excess-property 编译错误,而渲染器其实会 honour 它 —— 类型是唯一在拒绝一份能
正常工作的配置的那一层。今天不是运行期 bug,但这是 machine-readable surface
说谎的形状,对绝对信任类型的(AI)作者杀伤最大。
按 objectstack-ai#3559(PR objectstack-ai#3764)先落地的那一半已经定下的惯用形处理:给 entry 补
`[key: string]: unknown`,注释沿用父级 catch-all 的写法。⛔ 不动
`SelectOptionMetadata`,不把 `objectql.ts` 绑到 `field-types.ts`。**没有**改成
引用 core 的 `ActionParamOption`:`@object-ui/types` 是协议层、不吃 workspace
依赖(AGENTS.md §3 拓扑),因此是结构等价的 inline entry 加一条交叉引用注释。
`label` / `value` 保持必填且类型不变 —— open 不等于 optional;兜底也不是新增
选项键的邀请函,authoring gate 仍是 spec 的严格 `SelectOptionSchema`。
新增 `packages/types/src/__tests__/bulk-action-param-options.test.ts` 钉住四件事:
带 `color`/`visibleWhen` 的 entry 通过编译;`label`/`value` 仍必填(两条必须命中
的 `@ts-expect-error`);entry 经渲染器自己的投影后仍落进 `SelectOptionMetadata`
(无需 cast);spec 侧 `.passthrough()` 这个前置事实被断言而非假定。这些钉子是
真会跑的 —— `packages/types/tsconfig.test.json` 编译本包每个测试文件(objectstack-ai#3009)。
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Co-authored-by: Claude <noreply@anthropic.com>
akarma-synetal pushed a commit to akarma-synetal/objectui that referenced this pull request Aug 10, 2026
…objectstack-ai#3997) (objectstack-ai#4012)
第四个字段原子,与 PR objectstack-ai#3996 修掉的 `_shared.tsx` 三个原子形状完全相同 ——
`Label` 是控件的兄弟节点,没有 `htmlFor`,trigger 没有 `id` 也没有 `aria-label`。
它在自己的模块里,所以那三个修好之后它仍旧带着缺陷。标签与
`button[role=combobox]` 之间只有视觉邻接:焦点落上去读到匿名 combobox,可见标签是
一段无归属文本,`getByLabelText` 到不了它,点标签什么都不会发生。非测试调用点 18 处
(对象字段 / 数据集 / 仪表盘部件 / 应用导航 / 视图变体检查器),打开任一面板即渲染。
带 label 分支照 objectstack-ai#3994 的定型机制闭合:`React.useId()` 在原子内部生成 id,`Label` 补
`htmlFor`,id 落到 `PopoverTrigger asChild` 渲染出的那个 `Button`。⛔ 不落 `Popover`
—— Radix `Popover.Root` 是纯 context provider,不渲染 DOM,给它的 id 会被静默丢弃、
`for` 随之悬空(objectstack-ai#3976 / objectstack-ai#3994 已为此付过两次学费)。
## 无 label 分支:命名改成类型级要求,而不是消费端兜底
`label` 原本可选,无 label 分支是同缺陷更重一档 —— combobox 完全无名,而 18 处调用点
里有 5 处正是这么写的。没有采用宽松兜底(用 placeholder 合成名字会把「Select…」念成
字段名);改为「三条通道恰选其一」,零条和两条都不可编译:
- `label` —— 原子渲染可见标签并自持关联。已传 label 的 13 处不变。
- `ariaLabel` —— 重复行里本就没有可见标签、加一个会破坏栅格:应用导航 URL 过滤条件的
`field = value` 行、数据集的 join 列表、依赖查找的「添加字段」选择器。
- `id` —— 外部 `Label htmlFor` 已经持有命名。`DashboardWidgetInspector` 的 `Field`
包装器渲染 `Label htmlFor={id}` 并把同一个 id 交给被包控件,其余字段都履行了这个约定
(`Input id`、`SelectTrigger id`),只有 dataset combo 落不下去,因为原子不收 id ——
那个 `for` 指向一个没有任何元素持有的 id,是悬空 IDREF,比无标签更糟,因为工具会报告
一个解析不到的关联。
两条通道同时给出是 objectstack-ai#3961/objectstack-ai#3978 要避免的重复播报,故也一并禁掉。两种错误都没有组件能
自行发现并报告的运行期症状 —— 无名 combobox 渲染、布局、提交值全都正常,只对看不见它
的用户是错的 —— 所以检查只能发生在编写期,否则就不存在。
## 钉子与反向验证
- `_shared.labels.test.tsx`:第四原子直接加入既有的 `describe.each`(它已把「for 有
宿主 / 命中可聚焦控件 / 可访问名 / 单一命名通道 / 多实例不撞车」写成与组件无关的形
状),另加 trigger 落点、自定义值、`ariaLabel` 分支、外部 `id` 分支四组。
- `DashboardWidgetInspector.test.tsx`:真实调用点上钉 Dataset 标签解析到 combo trigger。
刻意只锁这一对,不做整面板「无悬空 for」扫描 —— `widget-color` 的
`ColorVariantPicker` 同样不收 id,那是另一个组件、本单范围外,已单独立单 objectstack-ai#4010。
- `InspectorComboField.naming.types.test.tsx`(新增,列入 `tsconfig.typetests.json`):
类型级断言。第一稿把 `@ts-expect-error` 写在 `_shared.labels.test.tsx` 里,变异实测
显示那是**假绿** —— 把命名改回可选,`tsc --noEmit` 完全通过,因为包的构建 tsconfig
排除 `**/*.test.tsx`、vitest 又擦除类型,没有任何编译器读它。这正是 objectstack-ai#3009 的失效模式,
故移入被 typetests 项目编译的独立文件;同一变异现在报 6 条错(4 条 assignability
断言 + 2 条 unused `@ts-expect-error`)。
反向验证三向(先预判后跑,变异未提交):撤 `htmlFor` → combo 8 行翻红,其中「mints
exactly one owner for the id」按预判保持绿(id 还在,只是没人指向它);id 改落 `Popover`
Root → 11 行翻红(多出 owner 计数、外部 id 分支、真实调用点钉);命名改回可选 → 运行期
全绿、信号只在 typetests。
Fixesobjectstack-ai#3997
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants

@os-zhuang@claude