Skip to content

fix(app-shell): the Studio RLS editor stops offering CHECK on a select or delete policy, and a refused save shows the server's explanation - #28884

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-1ofaqb
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-1ofaqb

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #28664

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:Studio「访问」支柱的行级安全编辑器里,select / delete 策略不再提供空白的 CHECK 输入框,改为一行说明;已经写了 CHECK 的保留输入框,并在下方显示 spec 自己的拒绝原文,不再显示「CEL 有效」。USING 和 CHECK 都为空的策略在 USING 下方显示 spec 的拒绝原文。存在这些问题时自动保存暂停,状态行说明原因。保存被拒时,横幅显示服务端每条 issues[].message,策略相关的按行号显示,不再只显示路径和 zod 代码。
  • 为什么改:服务端([finding] A check on a select or delete row-level policy is accepted by RowLevelSecurityPolicySchema and never evaluated — and it does not suppress the using default either; no lint reports it #19965)已正确拒绝 select / delete 上的 check 和没有任何谓词的策略,但编辑器照样提供 CHECK、显示「CEL 有效」,自动保存随后 422,横幅只剩 rowLevelSecurity.0.check [custom]。服务端的 422 消息按设计只给标题,原文在 issues[] 里,编辑器没读。
  • 风险与回滚:判定全部来自 RowLevelSecurityPolicySchema.safeParse,客户端不复述任何规则;编辑器不删除作者写过的内容。新增的保存暂停只在 spec 会拒绝的情况下出现。服务端和 spec 未改动。回滚即 revert 本 PR。
  • 先看:metadata-admin/PermissionAdvancedFacets.tsx 的 rlsClauseFindings(探针只带 operation / using / check)、metadata-admin/PermissionMatrixEditor.tsx 的 refusalText 与 rlsClauseRefusedCount、i18n/src/namespaces/studio/{en,zh}.ts 的三条新文案。
  • 两分钟验证:cd ui && pnpm exec vitest run packages/app-shell/src/views/metadata-admin/PermissionAdvancedFacets.rlsClauseFindings-28664.test.tsx packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.rlsAddPolicyHold-13113.test.tsx,预期 22 个用例全绿。
  • 需要你做的:无,席位落地。

What changes

  • Where the banner text came from (measured first). The meta door's 422 message is a headline by design: specValidationFindings in @objectstack/metadata-protocol returns only metadataIssueHeadline(issues) ("1 issue — PATH [code]") for the meta faces, and each issue's prose rides issues[], which MetadataClient's parseError already reads. The Studio Access pillar's door is PermissionMatrixEditPage, whose save catch printed err.message unless an issue named a policy name. So the fix is client-side; the server is right and unchanged.
  • The spec judges each policy's USING / CHECK pair. New rlsClauseFindings(policy) in PermissionAdvancedFacets.tsx runs RowLevelSecurityPolicySchema.safeParse on a probe that carries the row's operation, using and check beside a placeholder name and object, so a name still being typed does not stop the cross-field rules from running. Issues at check show under CHECK; issues at using or at the policy itself show under USING. Whether an operation admits a CHECK at all is read by probing a non-blank one. No operation list or rule is restated in the client.
  • CHECK on select / delete. A blank CHECK is not offered: the CHECK label stays with the note perm.rls.checkNotApplicable. A non-blank CHECK keeps its editor, shows the spec's message under it word for word, and withholds "Valid CEL" (through CelPredicateField's existing scopeIssue). Nothing the author wrote is pruned.
  • A policy with no predicate shows the spec's "At least one of using or check …" message under USING.
  • The save holds on what the door would refuse. rlsClauseFindingCount(draft.rowLevelSecurity) joins saveHeld in PermissionMatrixEditPage, read from the draft so it does not wait for the RLS tab to mount. The status line says perm.rls.clauseHeld. The CEL and unnamed-row lines keep their precedence.
  • A refused save prints every issue's message. rlsNameRefusal becomes refusalText: a rowLevelSecurity.N.name issue keeps its wording; any other rowLevelSecurity.N… issue reads "Not saved. Policy on row N + 1: MESSAGE" (perm.rls.policyRefused); an issue elsewhere follows the door's headline as PATH: MESSAGE. A refusal with no issues keeps the door's text. The banner span is whitespace-pre-line, so each line shows on its own.
  • Strings. Three keys in the studio namespace (perm.rls.policyRefused, perm.rls.checkNotApplicable, perm.rls.clauseHeld), en and zh. That table is typed Record<string, string> outside the locale packs, so Clause-②: no holds.
  • Bundle. @objectstack/spec/security is already a static runtime import of app-shell (permission-slice.ts imports objectPermissionGrants from it), so the schema adds no new entry to the bundle.

Tests

  • New: PermissionAdvancedFacets.rlsClauseFindings-28664.test.tsx, 14 cases. For select and delete, the CHECK finding's text equals the message RowLevelSecurityPolicySchema.safeParse answers and starts with the prefix the spec's own test pins ("check is never evaluated on a select policy:", and the delete one); a blank CHECK is not offered. Controls: all, insert, update offer CHECK with no finding. A policy with no predicate shows the spec's root message under USING on select, delete and all; controls for a non-blank USING and an update policy with only a CHECK. rlsClauseFindingCount counts across rows and judges an unnamed row.
  • Updated: PermissionMatrixEditor.rlsAddPolicyHold-13113.test.tsx. Case (d) now reads the headline followed by the issue's message. New (e): a refusal at rowLevelSecurity.0.check reads "Not saved. Policy on row 1: MESSAGE" with no [custom]; its control, a refusal with no issues, keeps the door's text. New (f): a named row with no predicate is held with the status line and sends nothing; a USING lets it go.
  • Fixture triage: PermissionMatrixEditor.serverVerdictHold-27482.test.tsx made its unrelated edit in CHECK on a select policy, which the editor no longer offers; its policy is now all (the verdict under test is about USING and does not read the operation). PermissionMatrixEditor.fieldEnvelope.test.tsx's facet mock now keeps the module's other exports.
  • Ablations, each through scripts/ablation-replace.mjs, anchor 1 → 0, restored to the HEAD blob with git diff HEAD empty:
    1. the clause parse replaced by { success: true }: 8 failed | 14 passed;
    2. checkApplies forced true: the two "blank CHECK is not offered" cases failed (2 failed | 12 passed);
    3. the save catch back to err.message: (c), (d), (e) failed (3 failed | 5 passed).

Acceptance notes

  • A brand-new "Add policy" row shows the no-predicate finding under USING at once, beside the existing "Give the policy a name" hint. The status line keeps the name hint first, as before.
  • The CHECK note is a fixed sentence; it does not name the operation, so no operation list is restated in copy.
  • The spec's messages are English; the inline findings show them as served, like the server verdict at a clause path does today.

Verification

Builds and type-check (at 1df41cf, base origin/main 67103cc)
  • turbo run build --concurrency=2 --filter='@object-ui/app-shell^...' --filter=@objectstack/formula --filter=@objectstack/sdui-parser --filter=@objectstack/lint --filter=@objectstack/client: 64/64 tasks, lock VERDICT command-exit 0.
  • pnpm --filter @object-ui/app-shell --filter @object-ui/i18n run type-check: both Done, VERDICT command-exit 0.
Tests
  • New and changed suites at 1df41cf: the new facets suite and rlsAddPolicyHold-13113, 2 files, 22 tests passed; serverVerdictHold-27482 and fieldEnvelope, 2 files, 9 tests passed.
  • Consumer sweep at bf3e741: every ui test file naming PermissionAdvancedFacets, PermissionMatrixEdit, rowLevelSecurity or perm.rls. (78 app-shell files, plus data-objectstack, fields, plugin-designer and scripts/__tests__/spec-symbol-ledger-app-shell-7265.test.ts), 80 files in three locked batches: 277 + 158 + 281 tests. The middle batch had 6 failures in the two files repointed above (a facet mock missing the new export, and a select fixture editing CHECK), both green after 1df41cf. CI's Test UI runs the rest of app-shell.
  • pnpm exec vitest run packages/i18n/: 94 files, 1438 passed, 13 skipped.
Derived gates (dispatch-gates --commands, at 1df41cf)

All 34 derived commands exit 0, reconciled with dispatch-gates --ran (34 derived, 34 run, 0 NOT-MEASURED). Among them: node scripts/check-sdui-manifest.mjs (exit 0, no registry change), pnpm --dir ui exec vitest run scripts/ (169 files, 4900 tests passed, after a spec rebuild), pnpm check:type-check-debt, pnpm check:nul-bytes and pnpm check:cross-package-test-inputs. The PR-body gates (check-adr-0087-registration --base origin/main, check-changeset-no-major --base origin/main, check-closing-keyword-parity) ran against this body through GITHUB_EVENT_PATH.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (No spec change.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (Left to CI's Lint UI.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: n/a.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

Generated by Claude Code

… pair by the spec's schema, and a refused save prints the server's issue messages

A blank CHECK is not offered on an operation the spec admits none on; a
written one keeps its editor with the spec's refusal under it. A policy with
no predicate shows the spec's refusal under USING. While either remains the
package door's autosave holds. A refusal now prints each issue's own message,
a policy's on its row, instead of the door's path-only headline.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTuqPevUec8TiUH9Wd
…se verdict

The server-verdict hold suite made its unrelated edit in CHECK on a select
policy, which the editor no longer offers; its policy is now `all`. The field
envelope suite's facet mock keeps the module's other exports.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTuqPevUec8TiUH9Wd
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · zhuangjianguo · session_01QsR2jUJ19MstFvFhjgiYTu

席位核对 · ACCEPT · 2026-11-02T03:12Z

Head-sha: 1df41cfc470c71fc9e02c63bdd4d2b9a13439187

  • Shape:
    • The PR is a draft against main. Its first content line is Fixes #28664, and no other card sits beside a closing keyword.
    • 10 files, +409 / −77. No governed path: check-governed-merges --pr 28884 reports NOT governed.
    • Clause-②: no and Metadata-protocol: none start their lines in the body and the changeset, as claimed (6567335853, amendment 6567354945).
    • The studio i18n namespace only gains keys.
  • Read in the diff:
    • rlsClauseFindings derives every inline finding from the spec's RowLevelSecurityPolicySchema.safeParse on a probe that carries the row's operation, USING and CHECK. There is no operation list in the client.
    • CHECK on select and delete is refused by the spec, so its field hides when blank. When it is not blank, the field shows the spec's own message inline and holds the autosave.
    • An empty USING gets its finding the same way.
    • In PermissionMatrixEditor, the save catch now prints each refusal issue's server message instead of the headline. This is generalized from the old name-only mapper.
  • Gates (check-runs on this head): 44 success, 11 skipped, 0 failed or pending. mergeable_state is clean. Main's newer commits touch none of the diff.
  • Tests (dev): 22 new and changed tests pass. The select and delete cases pin the inline text equal to the spec's parse message. The 80-file consumer sweep is green after two stale suites were repointed (serverVerdictHold-27482's select fixture, fieldEnvelope's facet mock). Three ablations went red and were restored. The type-check passes. Derived gates: 34 of 34 exit 0.
  • Accepted deviation: CelPredicateField.tsx changes only in the scopeIssue docblock wording, a comment.
  • Out of scope / NOT MEASURED: the seat ran no live Studio session. Skills-docs: is not owed.
  • Landing: ordinary queue landing, pr_ready then automerge_enable. Fixes #28664 closes the card on merge.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant