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 PR after
tsc output 0 errors TS1360 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.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 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 }', () => {
  const schema: 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

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Jul 30, 2026 9:45am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 27.9 KB 350 KB
Entry file index-B52fhQQg.js
Status PASS

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 8.20KB 2.97KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 7.57KB 2.97KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 22.10KB 4.37KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.12KB 3.41KB
auth (LoginForm.js) 17.86KB 5.29KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.43KB 2.09KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 35.76KB 9.11KB
auth (createAuthenticatedFetch.js) 4.37KB 1.69KB
auth (index.js) 2.25KB 1.01KB
auth (org-roles.js) 6.72KB 2.85KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 4.91KB 0.87KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 18.38KB 4.49KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 3.65KB 1.42KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.25KB 0.53KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 456.06KB 99.57KB
core (index.js) 2.16KB 0.78KB
create-plugin (index.js) 9.28KB 2.98KB
data-objectstack (index.js) 134.67KB 34.24KB
fields (index.js) 222.07KB 54.35KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 2.46KB 0.96KB
i18n (pickLocalized.js) 1.70KB 0.83KB
i18n (provider.js) 5.37KB 1.72KB
i18n (useObjectLabel.js) 25.17KB 5.80KB
i18n (useSafeTranslation.js) 3.26KB 1.44KB
layout (index.js) 38.45KB 10.67KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.05KB 1.53KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 6.84KB 2.42KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.71KB 3.79KB
plugin-calendar (index.js) 44.90KB 12.35KB
plugin-charts (index.js) 60.01KB 16.96KB
plugin-chatbot (index.js) 180.09KB 42.72KB
plugin-dashboard (index.js) 110.24KB 28.47KB
plugin-designer (index.js) 210.56KB 42.56KB
plugin-detail (index.js) 216.52KB 53.02KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 104.48KB 25.29KB
plugin-gantt (index.js) 162.26KB 39.53KB
plugin-grid (index.js) 180.86KB 47.45KB
plugin-kanban (index.js) 47.82KB 13.18KB
plugin-list (index.js) 102.39KB 24.18KB
plugin-map (index.js) 16.80KB 5.24KB
plugin-markdown (index.js) 13.65KB 4.67KB
plugin-report (index.js) 40.32KB 10.53KB
plugin-timeline (index.js) 25.75KB 7.32KB
plugin-tree (index.js) 8.36KB 2.81KB
plugin-view (index.js) 85.88KB 20.99KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 19.28KB 6.38KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.02KB 0.55KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 3.47KB 1.54KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 0.77KB 0.41KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (index.js) 2.00KB 0.96KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 0.20KB 0.18KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.04KB 1.93KB
types (system-fields.js) 2.39KB 1.17KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 1.08KB 0.64KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.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 main Jul 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>
Sign up for free to 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