Skip to content

fix(app-shell): the condition builder offers user.isPlatformAdmin instead of user.isAdmin and user.role - #28848

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

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

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #28833

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:元数据管理里的条件行构建器(Studio / Setup 的「可见条件」等)默认主题列表,把 user.isAdmin 换成 user.isPlatformAdmin,去掉 user.role;原始 CEL 编辑器的示例占位文字同样改教 user.isPlatformAdmin。新增一个测试,把列表里每个 user.* 主题拿到真实的表达式作用域里求值。
  • 为什么改:浏览器端绑定的用户对象(buildExpressionUser)根本没有 isAdmin,选它建出的行一求值就报错;user.role 是 better-auth 的旧字段,平台管理员读出来也是 user。两者都建不出「仅管理员可见」的门。
  • 风险与回滚:只改 ui/packages/app-shell 一个源文件里的两个常量和测试,不动 spec、服务端和已存的元数据。已存的 user.isAdmin / user.role 条件照常以行模式打开,主题原样保留,不会被改写。实测 examples/** 与平台应用里没有使用这两个主题的条件。回滚 = revert 本 PR。
  • 先看:ui/packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.tsx 的 CONTEXT_SUBJECTS 与 CEL_EXAMPLE_CLAUSES;再看新测试 ConditionBuilder.contextSubjectsBag.test.ts。
  • 两分钟验证:cd ui && pnpm exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.contextSubjectsBag.test.ts,应 1 个文件 8 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

CONTEXT_SUBJECTS, the row builder's default context subjects, now offers record.id, user.id, user.email and user.isPlatformAdmin:

  • user.isAdmin → user.isPlatformAdmin. The user object buildExpressionScope binds (under user, current_user, ctx.user and os.user) is buildExpressionUser's output. On both branches its members are id, name, email, role, isPlatformAdmin and positions, and there is no isAdmin. isPlatformAdmin is the platform-admin signal. It is false on the anonymous branch, so a row on it answers instead of faulting.
  • user.role dropped. It is in the bag, but it is better-auth's legacy sys_user.role scalar. ObjectStack never writes it (ADR-0068 D2), and it reads user for a signed-in platform admin too.
  • CEL_EXAMPLE_CLAUSES, the source of the raw editor's placeholder, teaches user.isPlatformAdmin instead of user.isAdmin.

Both constants are now exported so the new test can read them. Neither is re-exported by the package entry, so the published surface does not move. conditionScope.ts needs no edit. It names no user member: it hands the server tier RECORD_CONDITION_SUBJECTS (record.id only), the client tier inherits CONTEXT_SUBJECTS, and its root lists (CLIENT_CONDITION_ROOTS) are roots, not members. So it follows the list by construction.

The card says a row on user.isAdmin "never opens". The row faults, and what a fault does depends on which gate evaluates the row. An action's visible / disabled fail closed (useCondition with throwOnError, ActionEngine), and navigation withholds (evaluateNavigationVisibility), so on those the gate never opens. An object field's visible goes through evaluateVisibility, which fails open by documented design, so there it opens for everyone. Either way it never means "admins only".

Tests

  • ConditionBuilder.contextSubjectsBag.test.ts (new, 8 cases, unit project). It reads the member list off buildExpressionUser for a platform admin, a member and an anonymous visitor. It evaluates every offered user.* subject against createExpressionEvaluator (the real bag) on the evaluator's fail-closed seam. And it checks that a "user.isPlatformAdmin is true" row opens for the admin only. Controls: user.isAdmin faults on every branch, and user.role resolves to user for an admin and is not offered. The example placeholder's user clause evaluates on every branch.
  • ConditionBuilder.subjectVocabulary.test.tsx: the default-subject shape now lists user.isPlatformAdmin and neither removed subject.
  • ConditionBuilder.contextSubjects.test.tsx: the "still offers user.*" case holds user.isPlatformAdmin. Its lint leg passes for user.isAdmin too, because the engine lint accepts any member of an accepted root. That is why the new pin evaluates against the bag instead.
  • ConditionWidget.conditionSubjects.test.tsx: one doc comment's example spelling.
Ablation (scripts/ablation-replace.mjs, at 8f66ea8)
  • user.isAdmin re-added to CONTEXT_SUBJECTS: 3 failed, 5 passed (each branch: expected [ 'id', 'name', 'email', 'role', …(2) ] to include 'isAdmin'). Restored, blob equal to HEAD.
  • CEL_EXAMPLE_CLAUSES put back to user.isAdmin: 1 failed (the placeholder case), 7 passed. Restored, blob 90d12c3f equal to HEAD, git diff HEAD empty.

Acceptance notes

  • Stored conditions, measured with git grep at 2a4c0034 over examples, ui/examples, ui/apps and packages (non-test, non-markdown) for user / current_user / ctx.user / os.user with .isAdmin or .role. No authored condition uses either subject. The one hit is a test fixture, packages/metadata/src/__fixtures__/hotcrm-17.1-built-bare-root-predicates.artifact.json (current_user.role == "admin"). The other hits are doc comments in plugin-auth, spec and runtime that describe the legacy scalar.
  • A stored user.isAdmin or user.role row still opens in row mode. The builder appends an out-of-vocabulary subject as its own option, as for org.id (ConditionBuilder.contextSubjects.test.tsx). Nothing is rewritten on open.
  • The bag also carries user.name and user.positions, which are not offered. Adding subjects is outside this card.

Verification

All on the final head 457b72bb (origin/main 892eb668 merged, which carries #28832), after pnpm install --frozen-lockfile and turbo run build --filter='@object-ui/app-shell^...' plus formula, sdui-parser, lint and client (64 tasks, exit 0), under scripts/pm/os-verify-lock.sh.

  • Every app-shell test file naming ConditionBuilder, conditionScope, CONTEXT_SUBJECTS, celExampleForRoots or buildExpressionUser (git grep -l, --maxWorkers=2): 60 files, 667 tests passed. The same set without buildExpressionUser at 8f66ea84, before the merge: 53 files, 611 passed. CI's Test UI runs the rest of app-shell.
  • pnpm --filter @object-ui/app-shell run type-check (both tsc programs, the test one included): exit 0 at 457b72bb and at 8f66ea84.
  • ESLint on the 5 changed ts/tsx files: 0 errors. The two react-refresh/only-export-components warnings on the newly exported constants are the same class as the file's existing ones (RECORD_CONDITION_ROOTS, celExampleForRoots).
  • Derived gates (node scripts/pm/dispatch-gates.mjs --commands): 34 of 34 run at 457b72bb, each exit 0 (check:type-check-debt under the lock), including node scripts/check-sdui-manifest.mjs, pnpm --dir ui exec vitest run scripts/ and the PR-body gates with this body as GITHUB_EVENT_PATH. --ran reconciles 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN. Also 34 of 34 at 8f66ea84.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsR2jSnzNBkkhbAQrfcS1S

…tead of user.isAdmin and user.role

The row builder's default context subjects offered `user.isAdmin`, a member
`buildExpressionUser` never puts on the bag (a row on it faults), and
`user.role`, better-auth's legacy scalar that reads `user` for a platform
admin too. Offer `user.isPlatformAdmin` instead, teach it in the raw
editor's example placeholder, and pin every offered `user.*` subject
against the real expression scope on the admin, member and anonymous
branches.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jSnzNBkkhbAQrfcS1S
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests 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-02T00:42Z

Head-sha: 457b72bb27463dc33842e7b501e1aa18644f3ad1

  • Shape: the PR is a draft against main. Its first content line is Fixes #28833, and no other card sits beside a closing keyword. 6 files, +149 / −9, no governed path (check-governed-merges --pr 28848: NOT governed). Clause-②: no / Metadata-protocol: none start their lines in the body and the changeset, as claimed (6565352510). @object-ui/app-shell is private, so the two new exports (CONTEXT_SUBJECTS, CEL_EXAMPLE_CLAUSES) widen no published surface. The changeset is patch.
  • Read in the diff: CONTEXT_SUBJECTS now offers record.id, user.id, user.email and user.isPlatformAdmin. user.isAdmin was replaced and user.role dropped. CEL_EXAMPLE_CLAUSES teaches user.isPlatformAdmin. A stored row on either old subject still opens in row mode as its own option and is never rewritten. conditionScope.ts names no user.* member, so it needs no edit. The new ConditionBuilder.contextSubjectsBag.test.ts derives the members from buildExpressionUser on both branches and evaluates every offered subject against the real bag.
  • Gates (check-runs on this head): 44 success, 11 skipped, 0 failed or pending. mergeable_state is clean. The head carries main 892eb668, which includes docs(ui): platform-admin gate examples read isPlatformAdmin, not the legacy user.role scalar #28832.
  • Tests (dev): at 457b72bb, 60 files and 667 tests pass. Two ablations went red, and the blobs were restored to HEAD. The app-shell type-check exits 0. Derived gates: 34 of 34 exit 0.
  • Accepted correction to the card: a user.isAdmin row does not "never open" everywhere. A navigation gate withholds it, but a field's or action's visible gate fails open, which is documented policy (objectui#6443/[sweep] Three routes serve a shape their responseSchema never declares (#5882 #5950 #6442) #6487/fix(analytics): where 门的 undefined 比较数改为拒收,不再把整个键丢掉(#6386) #6445). The PR body carries the corrected wording. No stored condition in examples/** or the platform apps names either subject; the one hit is a test fixture.
  • Out of scope / NOT MEASURED: the bag also carries user.name and user.positions, which the list does not offer. That is outside this card and was not filed. No live Console run by the seat. Skills-docs: not owed.
  • Landing: ordinary queue landing, pr_ready then automerge_enable. Fixes #28833 closes the card on merge.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 2, 2026 00:44
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 2, 2026 00:44
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit a314318 Nov 2, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-fndqro branch November 2, 2026 01:05
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 tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant