Skip to content

fix(plugin-detail): declare code optional in isConcurrentUpdateError's narrowed type - #6474

Merged
os-support-ai merged 1 commit into
mainfrom
claude/issue-6421-concurrent-update-code-optional
Aug 26, 2026
Merged

os-support-ai merged 1 commit into
mainfrom
claude/issue-6421-concurrent-update-code-optional

Conversation

@os-support-ai

@os-support-ai os-support-ai commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6421

isConcurrentUpdateError no longer promises a code its runtime check knowingly accepts values without.

What moved

The exported predicate in packages/plugin-detail/src/ConcurrentUpdateDialog.tsx matches on two limbs — code === 'CONCURRENT_UPDATE' (the wire shape) or name === 'ConcurrentUpdateError' (the deliberate cross-realm discriminator, for a host that bundles the adapter twice so instanceof fails). Its narrowed type declared code: 'CONCURRENT_UPDATE' as a required literal, so for exactly the case the second limb exists to serve it handed the caller a property the value does not have.

One character in the return type, plus the comment that now explains why:

 export function isConcurrentUpdateError(err: unknown): err is {
-  code: 'CONCURRENT_UPDATE';
+  code?: 'CONCURRENT_UPDATE';

The two-limb runtime check is byte-identical. Per the triage ruling, only the narrowed type moves. The three body lines do not appear in the diff at all, and the other two copies of this predicate (data-objectstack narrows to the class; plugin-form's occSave returns bare boolean) are untouched.

Premise re-derived on origin/main — one contradiction to record

Verified rather than taken on faith, each with a positive control:

Card claim Measurement Verdict
the narrowed type requires code ConcurrentUpdateDialog.tsx:224 on origin/main: code: 'CONCURRENT_UPDATE'; confirmed
the name limb admits objects lacking code return e.code === 'CONCURRENT_UPDATE' || e.name === 'ConcurrentUpdateError'; confirmed
consumers read the fields optionally one consumer repo-wide, InlineEditSaveBar.tsx:183; its buildConflict(draft, err) takes err: any and reads only currentVersion / currentRecord confirmed, and stronger than claimed — the narrowing is discarded at that boundary, so nothing reads it at all

Contradiction: the claim comment's file face named packages/plugin-detail/src/index.tsx as "the predicate and its narrowed type". It is not there. index.tsx:74-76 is a re-export block; the definition lives in ConcurrentUpdateDialog.tsx:223, which is where the issue body itself points. This PR does not touch index.tsx — the export list is unchanged.

Public surface (clause ②) — stated, not inferred

  • Export list: unchanged. packages/plugin-detail/src/index.tsx is not in the diff. The built dist/index.d.ts:49 still reads export { ConcurrentUpdateDialog, isConcurrentUpdateError, } from './ConcurrentUpdateDialog.js';.
  • Narrowed type: one property moves from required to optional. The emitted dist/ConcurrentUpdateDialog.d.ts:53-58 now carries code?: 'CONCURRENT_UPDATE'; — the annotation reaches the published surface verbatim.
  • Not a widened surface. Nothing is added and nothing new is accepted: the parameter stays unknown, so the set of values the predicate takes is identical. What shrinks is what it promises. Calling this a widening would be backwards.
  • It is source-breaking for TypeScript consumers that read the narrowed code. err.code is now 'CONCURRENT_UPDATE' | undefined, so const c: string = err.code compiled before and will not now. Could a consumer have relied on the stronger promise? Yes — and that reliance was already wrong. On a name-only error the value is undefined at runtime; the old declaration was precisely the reason the compiler could not say so. The change converts a silent undefined into a compile error. No such consumer exists in this repo (only InlineEditSaveBar, via err: any).
  • Declared minor with the breaking semantics spelled out in the changeset, per AGENTS.md's no-major rule for the fixed group.

The pin, and why it is not blind

packages/plugin-detail/src/__tests__/ConcurrentUpdateDialog.narrowedCode-6421.test.tsx. Every assertion is labelled DISAGREES (red before, green after) or CONTROL (passes both ways, on purpose, naming the future wrong shape it guards).

  • It bites by assignability, over a named witness interface (name set, no code) rather than an object literal. That is load-bearing: excess-property checking fires only on fresh literals, so a literal would have gone red in both directions — on name, which is on neither version of the type — and measured nothing about code.
  • message: string on the witness is also load-bearing. The new narrowed type is all-optional, i.e. a weak type, and TypeScript rejects a source sharing no property name with a weak type; message is what keeps the pin a measurement of code rather than an accident of weak-type detection.
  • Nothing casts past it — there is no as any in the file, and the one cast present (nameOnly as { code?: unknown }) is a runtime read asserting the witness really is code-less.
  • Ghost-assertion controls: _PredicateStillNarrows fails if the predicate stops being an exported type predicate (Narrowed would collapse to never, which is assignable to everything and would satisfy every other pin silently); _CodeIsStillTheWireLiteral fails if someone "fixes" this by widening to code?: string; a throw inside the narrowing test fires if the name limb ever stops accepting a code-less error.
  • Not resolved through a stale dist/. tsc -p tsconfig.test.json --listFiles puts packages/plugin-detail/src/ConcurrentUpdateDialog.tsx (source, line 1424 of 1686) and the pin file (line 1465) in the program, with no plugin-detail/dist entry at all. The dependency closure was built first, and dependencies do resolve through their built .d.ts (packages/components/dist/... is in the same listing).

Reverse verification

Direction predicted before the run: putting the required code back turns tsc -p tsconfig.test.json red at exactly the three DISAGREES pins, while tsc --noEmit (which excludes tests) and vitest both stay green.

Mutation proven on disk by grepping both the injected and the deleted text — never a diffstat, never an editor's exit code: injected_required_form_count=1, deleted_optional_form_count=0.

MUT_SRC_TSC_EXIT=0        # tsc --noEmit — green, as predicted: no pin lives in that project
MUT_TEST_TSC_EXIT=2
  ConcurrentUpdateDialog.narrowedCode-6421.test.tsx(114,7):  error TS2344: Type 'false' does not satisfy the constraint 'true'.
  ConcurrentUpdateDialog.narrowedCode-6421.test.tsx(172,31): error TS2344: Type 'false' does not satisfy the constraint 'true'.
  ConcurrentUpdateDialog.narrowedCode-6421.test.tsx(179,3):  error TS2344: Type 'false' does not satisfy the constraint 'true'.
MUT_VITEST_EXIT=0         # Test Files 1 passed (1) / Tests 4 passed (4)

Lines 114 / 172 / 179 are _CodeReadsAsMaybeUndefined, _CodeIsOptional, _NameOnlyErrorIsAssignableToTheNarrowedType — the three DISAGREES pins, and only those. The controls at 150 / 156 / 163 stayed green, which is what makes the red a measurement of code's optionality rather than of the file failing to compile.

MUT_VITEST_EXIT=0 is the other half of the result and worth stating plainly: the whole runtime suite passes against the defect. A runtime-only pin could not have caught this, which is why the instrument here is a type pin.

Restore proven by state, not by exit code: worktree blob 7c30e8c69c1feb3d0d07a695b2a6ed86b587155c equals the HEAD blob, git diff HEAD empty, git status clean. An EXIT/INT/TERM trap held absolute paths resolved from git rev-parse --show-toplevel, and the restore named the ref — git checkout HEAD -- ABSPATH — rather than the bare git checkout -- ABSPATH, which reads the index and would have handed the mutation straight back.

Gates — verdict lines, exit codes captured before any pipe

All run on the final commit, 2bd48ad6d:

Gate Verdict
pnpm --filter @object-ui/plugin-detail type-check FINAL_TYPECHECK_EXIT=0, echoing > tsc --noEmit && tsc -p tsconfig.test.json (not a zero-match no-op)
pnpm exec vitest run over the affected files Test Files 5 passed (5) / Tests 76 passed (76)
pnpm --filter '@object-ui/plugin-detail^...' build os-verify-lock: VERDICT command-exit 0
pnpm --filter @object-ui/plugin-detail build BUILD_DETAIL_EXIT=0
node scripts/check-changeset-presence.mjs ✅ 2 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s)
node scripts/check-changeset-no-major.mjs exit 0
control-byte scan grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' over both edited files: no match

Test scope is the measured affected set, not a guess: the change is a type annotation plus a comment, so the only tests that can observe it are the three that import the module (ConcurrentUpdateDialog.narrowedCode-6421, InlineEditSaveBar, InlineEditSaveBar.savingNoProviderFallback) and the two that read its source text as a path string (i18n/residue-namespaces-3546, i18n/fallback-placeholder-spelling-3512). A full-package run was attempted first and was killed by the container's ~10-minute foreground cap.

Lint, narrowed and measured (counts from eslint's own --format json):

  • Diff: 2 files, 0 errors, 1 warning — react-refresh/only-export-components on the export function isConcurrentUpdateError line, pre-existing: the rule reads the file's export list, which this diff does not change (no export added, moved or removed; the line number shifted only because the doc comment grew).
  • Population eslint's config selected for the package: 161 files, 0 errors, 855 warnings (warnings are ambient here and ungated — errorCount 0, eslint exits 0).
  • Why nothing outside that set can move: linting in this repo is not type-aware — eslint.config.js extends tseslint.configs.recommended, not recommendedTypeChecked, and no parserOptions.project / projectService appears anywhere in it, so every file is linted from its own AST alone. A type annotation in one file cannot change any verdict in a file whose bytes did not change. The third changed file is a .md changeset, which is not in eslint's population at all (files: ['**/*.{ts,tsx}']).

The repo-wide farm (turbo run lint, the full check:* set) is CI's run and is left to it.

Found from #6375.


Generated by Claude Code

…r's narrowed type

The exported predicate matches on two limbs — `code === 'CONCURRENT_UPDATE'`
(the wire shape) or `name === 'ConcurrentUpdateError'` (the deliberate
cross-realm discriminator for a host that bundles the adapter twice, so
`instanceof` fails). Its narrowed type declared `code: 'CONCURRENT_UPDATE'` as
a required literal, so for exactly the case the second limb exists to serve it
handed the caller a property the value does not have: `err.code ===
'CONCURRENT_UPDATE'` type-checked and was `undefined` at runtime, with the
compiler agreeing it could not happen.

`code` is now optional, stating only what both limbs guarantee. The two-limb
runtime check is byte-identical — it is deliberate and documented, and the
diff carries nothing but the return type and the comment above it. No runtime
symptom existed to fix: the sole consumer (`InlineEditSaveBar`'s conflict
builder) reads only the optional `currentVersion` / `currentRecord` fields.

Pinned by `ConcurrentUpdateDialog.narrowedCode-6421.test.tsx`, which states the
invariant as an assignability relation — the value the runtime accepts through
the `name` limb must be assignable to the type the predicate returns — over a
named witness interface rather than an object literal, so excess-property
checking cannot make the pin pass for the wrong reason. It also adds the
runtime coverage of both limbs that this package had none of (the sibling
copies in `data-objectstack` and `plugin-form` each have theirs).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011SfZeFWrhGLHmfq61xbz4q
@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 52 chunks) 3233.8 KB 3266.6 KB
Main entry chunk (gzip) 157.4 KB 350 KB
Entry file index-DESrvNyz.js —
Status PASS —

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 11.30KB 4.28KB
app-shell (runtime-config.js) 18.10KB 6.51KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (ActiveOrganizationStorage.js) 25.05KB 9.16KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.18KB 10.59KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 8.46KB 3.43KB
auth (index.js) 3.19KB 1.44KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 5.13KB 2.35KB
collaboration (CommentThread.js) 26.08KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
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) 505.99KB 114.64KB
core (index.js) 5.30KB 2.13KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 173.10KB 47.96KB
fields (index.js) 238.89KB 60.02KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 4.28KB 1.75KB
i18n (index.js) 3.44KB 1.39KB
i18n (pickLocalized.js) 7.62KB 3.26KB
i18n (provider.js) 26.89KB 9.04KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 33.40KB 8.71KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 38.95KB 10.97KB
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.75KB
mobile (index.js) 1.55KB 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.72KB 0.42KB
mobile (useResponsiveConfig.js) 1.37KB 0.63KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 9.53KB 3.38KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 4.64KB 1.50KB
permissions (evaluator.js) 5.12KB 1.74KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 1.93KB 0.88KB
plugin-ai (index.js) 15.75KB 3.80KB
plugin-calendar (index.js) 46.66KB 12.84KB
plugin-charts (index.js) 64.66KB 18.32KB
plugin-chatbot (index.js) 188.60KB 44.82KB
plugin-dashboard (index.js) 133.48KB 34.49KB
plugin-designer (index.js) 211.90KB 42.74KB
plugin-detail (index.js) 245.26KB 62.38KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 131.78KB 32.19KB
plugin-gantt (index.js) 164.14KB 39.87KB
plugin-grid (index.js) 201.66KB 54.57KB
plugin-kanban (index.js) 53.16KB 14.65KB
plugin-list (index.js) 112.74KB 27.50KB
plugin-map (index.js) 20.09KB 6.62KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 43.51KB 11.94KB
plugin-timeline (index.js) 26.72KB 7.71KB
plugin-tree (index.js) 9.26KB 3.13KB
plugin-view (index.js) 84.82KB 20.79KB
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.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 56.69KB 19.03KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 2.05KB 1.04KB
react (schema-input.js) 2.32KB 1.24KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 5.41KB 2.34KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 4.93KB 2.24KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 12.13KB 3.65KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 7.54KB 2.63KB
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) 2.74KB 1.41KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
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 (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 4.72KB 2.24KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 2.59KB 1.31KB
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.05KB 1.93KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 3.40KB 1.71KB
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

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.

[finding] plugin-detail's isConcurrentUpdateError narrows to a required code: 'CONCURRENT_UPDATE' while accepting name-only errors that lack it

2 participants