Skip to content

fix(app-shell): the package permission door refuses the save when its re-read rejects (objectui#9420) - #9483

Merged
os-tesla merged 2 commits into
mainfrom
claude/issue-9420-permission-door-reread-refusal
Sep 14, 2026
Merged

os-tesla merged 2 commits into
mainfrom
claude/issue-9420-permission-door-reread-refusal

Conversation

@os-tesla

@os-tesla os-tesla commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #9420

What was wrong

PermissionMatrixEditPage.doSave's package door documents an ADR-0086 P0
guarantee in its own comment: merge only this package's slice back onto a fresh
read of the record, so rows contributed by other packages survive byte-for-byte.
The fresh read was client.layered(...).catch(() => null) and the merge base was
fresh?.effective ?? payload.

On the rejecting arm the guarantee inverted. payload is the editor's own
draft, which the load path already sliced down to this package's objects, so
mergePermissionSlice had no out-of-scope rows left to copy and the write PUT a
record with every other package's permission rows deleted — 200, no error, no
warning, on a security surface.

What changed

A rejected re-read now refuses the save. Nothing is PUT, and the refusal
reaches the author on the page's existing error strip — the same setError
channel a failed client.save already renders into. No new toast path, no retry
added (the client offers no retry idiom at this call site, and a retry would
narrow the window rather than restore the guarantee). The rejection stays inside
.catch, so it can never escape as an unhandled one; the refusal is raised inside
doSave's own try and caught by the handler that was already there.

One new i18n key, perm.save.rereadFailed, in both the en and zh tables of
the metadata-admin designer table.

What is deliberately NOT refused — and why it matters

Only a rejection refuses. MetadataClient.layered resolves a 404 as
{ effective: null, … } rather than rejecting, and that arm keeps the
?? payload base on purpose: a set that exists only as a package draft — what the
Studio Access pillar's "+ New" creates, before any publish — has no published rows
for anyone to lose, and refusing there would make the first save of every newly
created permission set impossible. Pinned, so the refusal cannot widen onto it by
accident.

The environment (whole-record) door never took this path at all: with no
packageId there is no slice merge and no pre-save re-read. Pinned as a guard in
the same file — same client, same edit, same click, only packageId differs — and
it still PUTs the whole record with force: false and no draft options.

Before / after — from the real run output, not an editor exit code

PermissionMatrixEditor.packageDoorRereadRefusal.test.tsx drives the REAL page
(load effect, real facet editors, real doSave) with layered resolving for the
load and rejecting for the save-time re-read.

BEFORE — the two production files reverted to ff1d5ea8d (the branch point)
with the new tests in place. Test Files 1 failed | 2 passed (3),
Tests 1 failed | 7 passed (8):

FAIL packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.packageDoorRereadRefusal.test.tsx
  > does NOT call client.save when the save-time layered re-read rejects
AssertionError: expected [ { name: 'sales_perms', …(3) } ] to deeply equal []

- []
+ [
+   {
+     "fields": {},
+     "label": "Sales",
+     "name": "sales_perms",
+     "objects": {
+       "a_account": {},
+     },
+   },
+ ]

That printed body is the card's one-shot probe, independently reproduced:
objects keys are ["a_account"] alone, fields is empty, b_order and
b_order.total are gone.

AFTER — same six files, fix in place: Test Files 6 passed (6),
Tests 24 passed (24).

Mutation and restoration were both proved on disk rather than read off an editor's
exit code: the mutated file's git hash-object differed from its HEAD blob, the
removed text grepped to 0 occurrences, and after the restore git status was empty
and git hash-object matched the HEAD blob again for both files. The revert ran
against the committed fix, so the red and green numbers come from real trees.

One sibling pin had to move, and it was measured rather than assumed

PermissionMatrixEditor.readDecorationStrip.test.tsx (landed with objectui#8181)
reached the base = payload fallback through the rejected re-read, and asserted
on the body that was PUT. This change removes that PUT, so its entrance no longer
exists. It was not weakened and not deleted: its subject, its assertions and
its controls are unchanged, and it now reaches the very same ?? payload fallback
through the other entrance — the 404 shape described above, which doSave still
saves on.

Measured, so the retarget is not merely asserted: with the strip removed at the
unwrap (stripReadDecorations( count 1 to 0 on disk, blob hash changed), the
retargeted pin goes red with expected { name: 'sales_perms', …(8) } to not have property "_diagnostics", and it is green again after restore with the file byte
identical to its HEAD blob. It still fails for exactly the reason it was written.

PermissionMatrixEditor.packageDoorFacets.test.tsx — the arm the card names as
already holding — is untouched and green.

Verification

Run from the repo root, in a dedicated worktree, all through the shared verify lock.

check result
pnpm exec vitest run over the six permission files Test Files 6 passed (6), Tests 24 passed (24)
pnpm exec vitest run packages/app-shell/ (the whole changed package) Test Files 703 passed (703), Tests 6889 passed | 1 skipped (6890)
pnpm --filter @object-ui/app-shell run type-check (tsc --noEmit + tsconfig.test.json) exit 0
pnpm --filter @object-ui/app-shell run lint exit 0, 0 errors, 3023 warnings (the package's standing warning baseline)
check:i18n-keys · check:i18n-drift · check:i18n-dead-keys · check:i18n-designer-parity all exit 0
check:control-bytes · check:new-line-citations exit 0
check-vi-mock-specifiers · check-vi-mock-inherit · check-vi-mock-override-shape · check-test-path-roots all exit 0
check-changeset-presence · check-changeset-no-major · check-changeset-overwrite all exit 0
check-governed-queue-guard --test over this PR's five paths NOT GOVERNED

The dependency closure was built first (pnpm --filter '@object-ui/app-shell^...' build),
because an unbuilt closure makes type-check report sixteen phantom
Cannot find module '@object-ui/…' errors that say nothing about this diff.

Acceptance notes

Noted while reading the code, not filed and not fixed here:

  • The ?? payload fallback has two entrances, and the card names only one.
    The second is a resolved-but-empty envelope (effective nullish), which is the
    404 shape. It is correct behaviour for a record the server does not hold, which
    is why it is kept — but the card's prose reads as though rejection were the only
    way in. Recorded here so the next reader of doSave does not re-derive it.

  • The card and the claim comment both cite the guarantee docblock at
    PermissionMatrixEditor.tsx:670. On ff1d5ea8d that line is a different
    ADR-0086 P0 mention, inside bulkSetObject; the guarantee this PR is about sits
    in doSave, immediately above the merge. The two other cited lines (the base
    fallback and the mergePermissionSlice call) matched exactly. This is AGENTS.md
    commandment [WIP] Update documentation for project #11 demonstrating itself.
    Filed rather than noted, because it is a reproducible defect in its own right:

  • objectui#9484 — at environment scope a rejected post-save layered read
    surfaces on the same error strip after a write that succeeded, and skips
    resetDraftBaseline, so the editor also keeps claiming unsaved changes for a
    record that is already persisted. Pre-existing, untouched by this PR (the ruling
    scoped this change to the package door), and reached by this PR's own
    environment-door guard test.

Serial constraint checked: objectui#7727 is pm:dispatched on the same directory
but on ConditionalFormattingEditor.tsx. No overlap — this PR touches
PermissionMatrixEditor.tsx, i18n.ts and two permission test files.

Clause-② stays no: nothing new is exported from @object-ui/app-shell, no
published type moved, no authoring surface widened. packages/app-shell/src/views/metadata-admin/index.ts
is not touched, and permission-slice.ts was read-only throughout — the refusal
belongs to the caller that chooses the merge base, not to the merge itself.

Session: https://claude.ai/code/session_011QreXiyMEqKLN4U5daMPVa


Generated by Claude Code


Generated by Claude Code

…ejects

`PermissionMatrixEditPage.doSave`'s package door merges the edited slice onto
a fresh `client.layered` read so rows contributed by other packages survive
byte-for-byte (ADR-0086 P0). The read was `.catch(() => null)` with
`base = fresh?.effective ?? payload`, and on the rejecting arm the guarantee
inverted: `payload` is the draft the load path already sliced down to this
package's objects, so `mergePermissionSlice` had no out-of-scope rows left to
copy and the write PUT a record with every other package's permission rows
deleted — 200, no error, no warning.

A rejected re-read now raises on the page's existing error strip (the channel a
failed `client.save` already uses) and nothing is written. Only a REJECTION
refuses: a record the server does not hold answers the 404 shape, which
`MetadataClient.layered` resolves as `{ effective: null, … }`, and that arm
keeps the `?? payload` base so the first save of a draft-only set is unchanged.
The environment (whole-record) door never took this path and is untouched.

`PermissionMatrixEditor.packageDoorRereadRefusal.test.tsx` drives the real page
through `doSave` on the rejecting arm and asserts `client.save` was not called,
with a resolving-arm control that PUTs through the same harness.
`readDecorationStrip.test.tsx` kept its subject and its assertions but moved to
the other entrance of the `?? payload` fallback, because the entrance it used
no longer reaches a PUT.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011QreXiyMEqKLN4U5daMPVa
Waiting only on the refusal text made the pre-fix reading a lookup TIMEOUT
rather than the PUT it actually is; waiting only on `layeredCalls` would race
the save that follows it. Settling on "refusal rendered OR a PUT landed" makes
the failure print the body the old code wrote — the one missing `b_order` and
`b_order.total`, which is the card's measured probe.

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

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 329 chunks) 3061.6 KB 3104.5 KB
Main entry chunk (gzip) 145.7 KB 350 KB
Entry file index-BIvUrP4e.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) 16.69KB 6.21KB
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) 11.08KB 4.58KB
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) 544.93KB 130.50KB
core (index.js) 8.52KB 3.41KB
create-plugin (index.js) 27.94KB 9.51KB
data-objectstack (index.js) 213.54KB 59.33KB
fields (index.js) 247.89KB 62.50KB
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) 8.87KB 3.64KB
i18n (index.js) 5.22KB 2.26KB
i18n (pickLocalized.js) 9.86KB 3.95KB
i18n (provider.js) 32.15KB 10.49KB
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.83KB 10.95KB
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) 13.52KB 4.88KB
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) 8.39KB 3.10KB
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) 14.81KB 3.63KB
plugin-calendar (index.js) 49.92KB 14.22KB
plugin-charts (index.js) 71.33KB 19.90KB
plugin-chatbot (index.js) 195.34KB 46.51KB
plugin-dashboard (index.js) 131.44KB 34.65KB
plugin-designer (index.js) 215.94KB 44.33KB
plugin-detail (index.js) 252.44KB 65.58KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 136.71KB 34.16KB
plugin-gantt (index.js) 167.62KB 41.26KB
plugin-grid (index.js) 212.55KB 57.83KB
plugin-kanban (index.js) 46.63KB 14.53KB
plugin-list (index.js) 112.67KB 27.68KB
plugin-map (index.js) 21.48KB 6.99KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 43.41KB 11.93KB
plugin-timeline (index.js) 30.07KB 8.74KB
plugin-tree (index.js) 10.58KB 3.72KB
plugin-view (index.js) 84.36KB 20.78KB
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) 99.04KB 32.62KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.63KB 2.18KB
react (schema-input.js) 4.25KB 2.04KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 6.58KB 2.74KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 5.66KB 2.50KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (kanban-quick-add.js) 3.89KB 1.87KB
sdui-parser (parse.js) 25.28KB 7.80KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 14.82KB 4.99KB
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.93KB 1.49KB
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 (strict-authoring-face.js) 14.04KB 5.36KB
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-tesla
os-tesla marked this pull request as ready for review September 14, 2026 10:14
@os-tesla
os-tesla added this pull request to the merge queue Sep 14, 2026
Merged via the queue into main with commit df51bec Sep 14, 2026
38 checks passed
@os-tesla
os-tesla deleted the claude/issue-9420-permission-door-reread-refusal branch September 14, 2026 10:34
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.

The package permission door deletes other packages' rows when the save-time layered re-read fails

2 participants