Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

fix(core): DataScopeManager reads scope-rule fields as own members and refuses coercing comparisons - #8048

Merged
os-steve merged 1 commit into
mainfrom
claude/issue-7751-datascope-guards
Sep 6, 2026
Merged

os-steve merged 1 commit into
mainfrom
claude/issue-7751-datascope-guards

Conversation

@claude

@claude claude Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7751

Brings DataScopeManager up to one hardening standard with its sibling evaluateCondition in @object-ui/permissions, and pins the standard as a table both evaluators are run against, so a third divergence turns a test red instead of waiting for the next contract review.

Both gaps re-measured against head source, not taken on the card's word

Probed on origin/main at 8d40c18 before any edit:

rule verdict before
{ field: 'constructor', operator: 'ne', value: 'x' } admits every row confirmed, on [1, 2, 3] and on object rows
{ field: 'age', operator: 'gte', value: 0 } admits null, '10' confirmed, and also true, false, '', []

Two things the card did not name, both measured the same way:

  • The name list is not the class. toString, valueOf, hasOwnProperty, isPrototypeOf are not among the three refused spellings, and each one admits every row on ne / nin exactly as constructor did.
  • contains coerces too — String(filterValue) made { operator: 'contains', value: 1 } match the record value '10'. Same defect class, same function, so it is fixed here and called out rather than left for a third card.

The card's three open questions, answered by measurement

1. Is the sibling's shape the target? No — adopt its property, not its lines. Two measurements say so.

The sibling refuses three names and reads the rest with hasOwnProperty. hasOwnProperty collapses inherited into absent, and absent ADMITS on a negative operator, so the sibling itself still returns true for { field: 'toString', operator: 'neq' } on every record, and true for a neq rule against a value the record inherits. Copying it would have closed three spellings, left the class open, and widened one case. Filed as #8044 with the table.

The sibling also requires typeof === 'number' on both sides of every ordered comparison. Measured, that predicate denies every row for { field: 'created', operator: 'gte', value: '2023-01-01' } — ISO date strings, plain string ranges and Date objects all order correctly on this evaluator today, and none of those comparisons coerces anything. What each evaluator's callers depend on differs too: evaluateCondition is not exported from @object-ui/permissions (its index.ts exports evaluatePermission only) and has no caller outside its own test, so its extra strictness costs it nothing; DataScopeManager is on @object-ui/core's public entry via export * from './data-scope/index.js', so the same predicate would be a public, silent, fail-closed break.

So the property adopted is no coercion, and no value that is not the record's own data. Where that makes this evaluator stricter than the sibling (inherited members) and where it leaves it broader (same-kind non-numeric ordering), both are asserted in the pin with the reason, not left to be rediscovered.

2. Does fixing gap 2 change any currently-admitted row for a legitimate rule? Yes, and the changeset names each shape in its own paragraph. A numeric rule over a dataset where numbers arrive as strings (JSON, CSV import, unparsed form field) stops matching those records. A rule reading a field that records inherit from a shared prototype stops matching. A contains rule written with a non-string value stops matching.

3. Operator spelling. Untouched. ne/nin here, neq/not_in there, and the sibling's is_null/is_not_null which this evaluator does not implement, are all exactly as they were — that is #7750's question. The conformance table addresses each evaluator through an explicit spelling map so that it takes no position on which vocabulary is right.

Stop-condition: cleared by measurement, zero widenings

The dispatch's stop-condition was that any input refused today and accepted after flips the Clause-② reading. Measured rather than argued: a differential matrix of 2772 cases — 17 value kinds on both sides of 9 operators, plus prototype member names, genuinely absent fields, inherited members, and null-prototype records — run against the source before and after.

CASES=2772
WIDENED (refused before, accepted after) = 0
NARROWED (accepted before, refused after) = 352

Broken down: 295 ordered comparisons that only succeeded by coercion, 45 prototype member names, 12 inherited members. Zero change to the genuinely-absent-field family, which is the regression this shape is most likely to cause — "this row has no status" keeps every verdict it has always had. Both gaps are narrowings; Clause-②: no stands.

The pin

packages/core/src/data-scope/__tests__/DataScopeManager.hardening.test.ts, 41 assertions in four blocks. The last one is the anti-divergence mechanism: one shared table of hardening cases run against both evaluators, each addressed in its own spelling. It also asserts the two known gaps in the sibling (#8044) and the one deliberate divergence, each written as an assertion rather than a comment, so closing #8044 turns this red and points its implementer at where the standard is recorded.

evaluateCondition is not on the sibling package's public entry, so the pin reaches it by relative path — the same shape as the two existing cross-package test imports on main (activityItemType-6730.test.ts, degradeSetTwin-5880.test.ts). No bare specifier, so no dependency edge and no phantom import.

Verification

Every exit code captured before any pipe.

check verdict line
vitest run packages/core/ Test Files 120 passed (120) · Tests 2559 passed (2559), exit 0
vitest run packages/core/src/data-scope/ packages/permissions/ Test Files 12 passed (12) · Tests 189 passed (189), exit 0
pnpm --filter @object-ui/core run type-check exit 0, after pnpm --filter '@object-ui/core^...' build
check:control-bytes OK (scanned 6457 tracked text file(s)), exit 0
check:phantom-deps Every in-scope import is declared by the package that publishes it., exit 0
check:self-import No package names itself inside its own src/., exit 0
check:unreferenced-sources Every shipped source file in every covered package is reachable., exit 0
check:published-tsconfig-exclude all 34 enforced package(s) carry the directory form., exit 0
check-type-check-coverage.mjs 42/42 packages compile their tests, exit 0
check-changeset-presence.mjs 1 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s), exit 0

The pin is proved to be readable by the type program rather than assumed: tsc -p packages/core/tsconfig.test.json --listFiles reads 669 files and both the pin and the sibling evaluator are among them.

Lint. Both the narrowed run and the full union, on the final commit 187e014.

  • Narrowed, eslint on the two changed files: exit 0, 0 errors; 8 warnings on DataScopeManager.ts, all @typescript-eslint/no-explicit-any, against 7 on the same file at 8d40c18 — the one added warning is readField(row: any, …), matching the annotation the function it replaces already carried. The pin file: 0 errors, 0 warnings.
  • Union, eslint . --no-inline-config --format json: population 4359 files, read from eslint's own config rather than assumed; 93 errors and 12168 warnings repo-wide, none of them in this diff's two files, which report 0 errors each in that same run.
  • The narrowing would have been sound on its own: this repo's eslint.config.js sets no parserOptions.project and no projectService, so linting is not type-aware and this diff cannot move the verdict of any file it does not touch.

⚠️ Recorded because it changes how a number should be read: a first union run overlapped the ablation below and therefore measured a mutated snapshot of DataScopeManager.ts (it reported a no-unused-vars warning for PROTOTYPE_FIELD_NAMES, which only exists while the field guard is ablated). That reading was discarded and both runs above were re-taken against the clean committed tree.

Not run locally, declared: check:readme-exports, check:dist-completeness --all and check:node-esm-load all require a full pnpm build (they report run pnpm build first against an unbuilt tree). This diff adds and removes no exported symbol — readField, isOrderedPair, isDate and PROTOTYPE_FIELD_NAMES are module-private — and touches no README, so its input to those gates is unchanged.

Ablation — the pin is proved able to fail

Two legs, each mutating the committed implementation on disk, each proving the mutation landed by grep count and by git hash-object differing from the HEAD blob, each restored with git checkout HEAD -- path under an EXIT INT TERM trap and verified byte-identical afterwards.

leg mutation result
field guard field read replaced by the previous unguarded row[field] Tests 16 failed, 25 passed, exit 1
comparison guard isOrderedPair removed from the four ordered arms Tests 13 failed, 28 passed, exit 1

Restored blob f9763a2 matches the HEAD blob in both legs; git status clean. The pin imports the module by relative path, so it resolves from src and no stale dist can flatter either leg.

Declared deviations

  • File surface extended by one file. The dispatch named the source plus "a co-located pin"; the pin is a new file, DataScopeManager.hardening.test.ts, rather than an addition to the existing DataScopeManager.test.ts, so the standard has a named home. That existing file is unchanged and still passes.
  • contains folded in as a bounded in-place fix: same defect class as gap 2 (an unwritten coercion in a comparison arm), same function, same file, same gate family, no new verification surface.
  • Channel switch declared. The de-duplication search before filing finding(permissions): evaluateCondition's prototype-name guard closes three spellings, not the class — { field: 'toString', operator: 'neq' } still admits every record #8044 could not use REST — GET /search/issues is not a repo-scoped path and returns 403 through the proxy (a repo-scoped read probe returned 200 with a live 15000/hour credential in the same container). One targeted MCP search_issues call was used instead; it returned 6 results, none of them this gap.

Generated by Claude Code


Generated by Claude Code

…comparisons

`DataScopeManager.applyFilters` had two fail-opens on a row-level permission
boundary, both measured against the previous source.

A rule naming a prototype member evaluated against the prototype chain rather
than the record, so `{ field: 'constructor', operator: 'ne' }` returned the
entire dataset. The field read now has three cases: a refused name denies, an
own member is read, and a name that is not own but still resolves on the
record's prototype chain denies rather than collapsing into "absent" — which is
what keeps the change a narrowing and what closes the class rather than three
spellings of it.

The ordered operators compared without a type guard, so `{ field: 'age',
operator: 'gte', value: 0 }` admitted `null`, `'10'`, `true`, `false`, `''` and
`[]` by coercion. Both sides must now be the same comparable kind — both
numbers, both strings, or both Dates — which refuses every coercion without
denying the ISO date strings, string ranges and Date objects that order
correctly here today. `contains` likewise requires its rule value to be a
string instead of calling `String()` on it.

Measured over a 2772-case differential matrix: 352 verdicts narrowed, zero
widened, and zero change to the genuinely-absent-field family.

Operator spelling is deliberately untouched.

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

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 50 chunks) 3186.0 KB 3191.4 KB
Main entry chunk (gzip) 143.5 KB 350 KB
Entry file index-DuMkzIKe.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) 15.67KB 5.75KB
app-shell (runtime-config.js) 20.68KB 7.36KB
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) 497.06KB 113.79KB
core (index.js) 6.96KB 2.79KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 182.08KB 50.62KB
fields (index.js) 242.44KB 61.25KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
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.65KB 1.47KB
i18n (pickLocalized.js) 7.62KB 3.26KB
i18n (provider.js) 26.89KB 9.04KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 34.34KB 9.17KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 38.84KB 10.94KB
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.99KB 0.87KB
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 (useSpecGesture.js) 4.39KB 1.66KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 11.71KB 4.29KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.24KB 2.16KB
permissions (discardProofCache.js) 1.04KB 0.55KB
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) 4.83KB 2.27KB
plugin-ai (index.js) 15.16KB 3.68KB
plugin-calendar (index.js) 47.29KB 13.18KB
plugin-charts (index.js) 70.43KB 19.71KB
plugin-chatbot (index.js) 193.53KB 46.05KB
plugin-dashboard (index.js) 131.41KB 34.43KB
plugin-designer (index.js) 211.51KB 43.01KB
plugin-detail (index.js) 247.59KB 63.48KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 131.01KB 32.32KB
plugin-gantt (index.js) 167.16KB 40.99KB
plugin-grid (index.js) 208.56KB 56.63KB
plugin-kanban (index.js) 52.30KB 14.49KB
plugin-list (index.js) 113.24KB 27.66KB
plugin-map (index.js) 20.35KB 6.77KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 43.42KB 11.92KB
plugin-timeline (index.js) 29.95KB 8.67KB
plugin-tree (index.js) 9.19KB 3.19KB
plugin-view (index.js) 84.33KB 20.75KB
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) 81.07KB 26.86KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.63KB 2.18KB
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) 20.57KB 5.88KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 10.35KB 3.60KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 1.00KB
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 (expression.js) 0.20KB 0.18KB
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.74KB 2.25KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 4.73KB 2.28KB
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 (select-option.js) 0.20KB 0.19KB
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) 8.11KB 3.32KB
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-steve
os-steve marked this pull request as ready for review September 6, 2026 13:26
@os-steve
os-steve added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 5aed9e4 Sep 6, 2026
33 of 34 checks passed
@os-steve
os-steve deleted the claude/issue-7751-datascope-guards branch September 6, 2026 13:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

2 participants