Repository navigation
Commit 4c5023a
fix(ui-core): read a bare-string predicate as CEL shorthand, as the spec and server do (#27584)
domain:ui#1 · os-sales · session_01L6bhgXU26UBEjd1KKHgNEx
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu7yHaRjPxrzzz1THaFZtY5c)_
Fixes #27457
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #27587
## 维护者速读
- 改了什么:控制台把「裸字符串」谓词(导航 `visible`、页面 `visibleWhen`、动作
`visible`/`disabled` 等)当作 CEL 求值,与 `{ dialect: 'cel' }` 信封走同一个引擎;只有
`${…}` 模板仍走旧 JS 求值器。
- 为什么改:spec 把裸字符串定义为 CEL 简写,服务端也按 CEL 读;控制台却按旧 JS 语法读,`'org_owner' in
current_user.positions`、`size(page.items) > 0` 这类 CEL
写法在控制台报错,导航项对所有人隐藏、页面区块不渲染(ADR-0032:只有一种表达式语言)。
- 风险与回滚:只依赖 JS 语法的裸字符串谓词(`===`、`.includes()`、`.length`、读不存在的 `data.*`
键)现在会故障并按各入口原有故障策略处理(导航/显示门隐藏,`disabled` 置为禁用);仓内无此类已编写元数据(实测见下)。回滚即
revert 本 PR。
- 先看:`ui/packages/core/src/evaluator/ExpressionEvaluator.ts`(`if
(!unwrappedEnvelope)`
分支)、`ui/packages/core/src/evaluator/predicateInput.ts`(字符串分支)、`ui/packages/core/src/evaluator/listConditional.ts`(行谓词路由)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/providers/__tests__/navigationVisibility.bareCel-27457.test.ts
packages/react/src/__tests__/SchemaRenderer.bareCelVisibleWhen-27457.test.tsx`,预期
8 个测试全绿。
- 需要你做的:无,席位落地。
## What changes
The spec defines a bare string in a predicate slot as shorthand for `{
dialect: 'cel', source }` (`ExpressionInputSchema` /
`EvaluatedExpressionInputSchema`), and the server reads it that way. The
console read it on the legacy JS grammar, so a CEL-only predicate
faulted: a nav entry `visible: "'org_owner' in current_user.positions"`
was withheld from everyone, and a page block `visibleWhen:
"size(page.items) > 0"` never rendered, while the same source as an
envelope worked.
- `ExpressionEvaluator.evaluateCondition` (`@object-ui/core`): a bare
string now takes the CEL route (`evaluateCelCondition`), the same one a
`cel` envelope takes, with the same `onFault` / `throwOnError` policy.
Only a `${…}` template and the `source` of an envelope whose dialect is
not `cel` stay on the legacy path.
- `toPredicateInput`: a bare string normalizes to `{ dialect: 'cel',
source }` instead of being wrapped as `${…}`; an already-`${…}` string
is returned untouched as before.
- `evalRowPredicate` (`listConditional.ts`): only a `${…}` template is
routed to the legacy engine; every other bare string is CEL. The
one-time legacy-syntax warning still fires for any legacy marker.
- Comment-only updates in `ExpressionProvider.tsx` and
`SchemaRenderer.tsx` where they described the old bare-string route.
Why this is the normalization point: `evaluateCondition` is the single
funnel every console predicate reader reaches (SchemaRenderer,
ExpressionProvider's nav and visibility gates, ActionEngine, the hooks),
and several of them hand it the authored value without normalizing
first. Reading the bare string there is the console's equivalent of the
server's `normalizeExpression` input step; `toPredicateInput` emits the
same envelope for the callers that normalize first, so both orders reach
one engine. No legacy path remains for the shorthand.
Branch name: this card was worked in a platform-assigned card-thread
branch (`claude/project-thread-054wyf`), not the
`claude/issue-27457-SLUG` shape; the claim names this branch.
## Tests
- New acceptance tests:
-
`app-shell/src/providers/__tests__/navigationVisibility.bareCel-27457.test.ts`:
the nav `visible` bare string `'org_owner' in current_user.positions` is
true for the holder and false for the member, with no fault line; the
envelope control reaches the same verdicts; `evaluateVisibility` agrees;
a legacy-only `===` spelling is withheld with one report, and its `==`
control is shown.
-
`react/src/__tests__/SchemaRenderer.bareCelVisibleWhen-27457.test.tsx`:
page `visibleWhen` `size(page.items) > 0` is shown with items and hidden
without, `'org_owner' in current_user.positions` shows the holder and
hides the member, the envelope control agrees, and a legacy-only `===`
spelling is withheld with one report.
- Pin sweep: every pin of the "bare strings stay legacy" window was
flipped to assert the CEL verdict substantively (fault reason text,
report count, shown/hidden state): `ActionEngine.visibility`,
`ActionRunner.disabledGate`, `declaredPredicate`, `predicateInput`,
`listConditional`, `actionPredicate.parity`, `useExpression`,
`record-alert.rowBinding`, `record-block-record-reach`,
`SchemaRenderer.nodeGateDataPredicate`,
`SchemaRenderer.productionPredicateFaultWarning`,
`SchemaRenderer.disabledGateFaultDiagnostic`, `DeclaredActionsBar`. Legs
that pinned the adapter-only `data.*` diagnostic keep their coverage
through the `${…}` template spelling, which still reads on the legacy
engine.
## Acceptance notes
- Narrowing: a bare-string predicate that relies on JS-only syntax
(`===`, `!==`, `?.`, `??`, `.includes(…)`, `.length`, or reading a
`data.*` key the scope does not hold) now faults instead of evaluating.
Measured over the repository: 1604 bare predicate literals, 127 do not
parse as CEL; the 54 outside tests are i18n label strings, lint-script
fixture prose, regex-escaped zod description examples and one className,
none of them an authored predicate. The 73 in tests are fixtures,
flipped above where they pinned the legacy reading. The changeset
carries a BREAKING note that points authors to the CEL spelling and
lists no FROM-to-TO rewrites (ADR-0087 disposition `not-required
(no-migration-prescription)`); the per-spelling rewrite guidance lands
in the skills under follow-up #27587.
- The adapter-only `data.*` diagnostic (objectui#5687) fires only on a
clean evaluation, so it is now reached only through `${…}` templates; a
bare `data.*` miss reports on the fault leg instead (pinned).
- On the `throwOnError` callers (dev-mode visibility gate,
`DeclaredActionsBar`), a CEL fault reports the generic `CEL predicate
failed to evaluate: SOURCE` line, while `onFault` callers report `[kind]
message` (for example `No such key: status`). This split already existed
for envelopes and is unchanged here.
- In-place fix declared:
`ui/packages/core/src/evaluator/listConditional.ts` is outside the
claim's listed file surface. Same defect class (its row-predicate router
sent bare strings with legacy markers to the JS engine), mechanical, no
other claim on the file, same gate families; the ablation below shows
its test turns red without it.
- Out of scope, not changed:
`ExpressionEvaluator.evaluatePlainCondition` still reads a bare string
on the legacy path.
## Verification
<details><summary>Ablations (each through scripts/ablation-replace.mjs
under the verify lock, restored to HEAD after)</summary>
- `ExpressionEvaluator.ts` anchor `if (!unwrappedEnvelope) {` replaced
with `if (false) {` (legacy route restored): 6 failed, all in the two
acceptance files (nav 3, page 3).
- `predicateInput.ts` string branch replaced with `return
wrapIfBare(value);`: 5 failed across `ActionEngine.visibility`,
`declaredPredicate`, `predicateInput`, `useExpression`.
- `listConditional.ts` router `source.includes('${')` replaced with
`isLegacyDialectSource(source)`: 1 failed (the bare `===` CEL
parse-fault report).
</details>
<details><summary>Local test runs</summary>
- `@object-ui/core` plus every edited and new test file, one run under
the verify lock: 227 files, 4326 passed, 27 skipped, 2 failed in
`SchemaRenderer.nodeGateDataPredicate` (dev-line reason text); those two
assertions were corrected and the file re-run: 24/24 passed.
- Type-check (`type-check`) of `@object-ui/core`, `@object-ui/react`,
`@object-ui/app-shell`, `@object-ui/plugin-detail`,
`@object-ui/console`: exit 0.
- eslint on changed files: 0 errors.
</details>
<details><summary>Gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 34 commands on this diff; each was
run with its exit code recorded, plus `pnpm check:changeset-fixed` for
the `.changeset` roster. All 35 exit 0. `--ran` reconciliation: 34
derived, 34 run, 0 NOT-MEASURED, 0 UNRUN.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgVn2m1FLfCPDLtAfE3)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgVn2m1FLfCPDLtAfE3
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent af515db commit 4c5023a
24 files changed
Lines changed: 614 additions & 147 deletions
File tree
- .changeset
- ui
- apps/console/src/__tests__
- packages
- app-shell/src
- providers
- __tests__
- views/__tests__
- components/src/__tests__
- core/src
- actions/__tests__
- evaluator
- __tests__
- plugin-detail/src/renderers/__tests__
- react/src
- __tests__
- hooks/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
554 | | - | |
| 554 | + | |
| 555 | + | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
607 | | - | |
608 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
609 | 611 | | |
610 | 612 | | |
611 | 613 | | |
| |||
620 | 622 | | |
621 | 623 | | |
622 | 624 | | |
623 | | - | |
| 625 | + | |
624 | 626 | | |
625 | 627 | | |
626 | 628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 27 | + | |
| 28 | + | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
250 | | - | |
| 252 | + | |
251 | 253 | | |
252 | 254 | | |
253 | 255 | | |
| |||
271 | 273 | | |
272 | 274 | | |
273 | 275 | | |
274 | | - | |
| 276 | + | |
275 | 277 | | |
276 | | - | |
| 278 | + | |
277 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | | - | |
| 286 | + | |
281 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
282 | 292 | | |
283 | 293 | | |
284 | 294 | | |
285 | | - | |
286 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
287 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
288 | 304 | | |
289 | 305 | | |
290 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
269 | 291 | | |
270 | 292 | | |
271 | | - | |
| 293 | + | |
272 | 294 | | |
273 | 295 | | |
274 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
337 | | - | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
364 | | - | |
365 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
375 | 379 | | |
376 | 380 | | |
| 381 | + | |
377 | 382 | | |
378 | 383 | | |
379 | 384 | | |
| |||
413 | 418 | | |
414 | 419 | | |
415 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
416 | 441 | | |
417 | 442 | | |
418 | 443 | | |
| |||
0 commit comments