Repository navigation
Commit ba875d2
fix(studio): a renamed validation rule keeps the server verdict's hold on its guard (#31549)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbVq7nzkk5jEoQes96mHQY8d)_
Fixes #27482
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:Studio 数据支柱「验证规则」页里,规则改名后(用「新建」建出的规则,名称会随错误提示语自动变化;或直接改 API
名称),服务器对该规则条件的拒绝判定会跟着新名称走,下一次自动保存照样被拦住,并显示「尚未保存」提示行。权限集和钩子面板的拦截提示语从「请先修复
CEL 语法错误再保存」改成「请先修复表达式错误再保存」,因为它也拦服务器的非语法拒绝。
- **为什么改**:#27612 / #28027
已让服务器判定能拦自动保存,但面板按规则名称记判定数,改名后数字留在旧名下被清掉,条件编辑器只在数字变化时才重报,于是「新建」出来的规则在服务器标红后每次编辑仍然
PUT 200,直到发布被拒(QA #29672、#29893 实测,本卡在 `main` 上实测复现)。
- **风险与回滚**:只改 `ObjectValidationsPanel.tsx` 里的计数归属(约 20 行)和 studio 词条
en/zh 各一行;不动
spec、lint、服务端,不在客户端复制发布规则。首次保存仍会发出(服务器只评判已保存的草稿);改条件文本本身仍会发出以换取新判定。回滚即
revert。
-
**先看**:`ui/packages/app-shell/src/views/studio-design/ObjectValidationsPanel.tsx`
的 `renameCel` / `renamedTo` / `reportCel` 与 `patchRule` 第一行。
- **两分钟验证**:`cd ui && pnpm exec vitest run
packages/app-shell/src/views/studio-design/DataPillar.validationVerdictHold-27644.test.tsx`,预期
9 个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
- **`ObjectValidationsPanel.tsx`: a rule's verdict follows its name.**
The panel keeps each rule's blocking CEL count by rule name
(`reportCel(sel.name!, count)`) and prunes names no longer in the draft.
A rule the panel minted takes its name from its message
(`patchMessage`), and the name input renames too. The guard's
`ConditionBuilder` reports only when its count changes, so a rename left
the count under the old name, it was pruned, and the new name never got
one: the served verdict stayed on screen while every later edit
autosaved. Now:
- `patchRule` calls `renameCel(old, new)` whenever a patch carries a
`name`, which moves the kept count to the new name.
- `renameCel` also records the rename in `renamedTo`, and `reportCel`
resolves a name through it. A report still in flight under the old name
(the editor's effect ran on the render before the rename) lands on the
rule's current name instead of being stranded. Without this, the new
test's minted-rule case was red in 3 of 4 runs.
- `placeNewRule` drops a `renamedTo` entry for the name it places, so a
new rule that reuses a name a rename left reports as itself.
- **`perm.cel.saveBlocked` copy** (studio namespace, `en.ts` and
`zh.ts`, the only two packs that carry it): "Fix the CEL syntax errors
before saving." → "Fix the expression errors before saving."; zh 「请先修复
CEL 语法错误再保存。」 → 「请先修复表达式错误再保存。」. The line holds server refusals too
(`rls-predicate-unenforceable` measured live), not only syntax errors.
Read by the permission set editor's held line and Save title and by
`ObjectHooksPanel`'s held line. The two `metadata-admin` pins of the old
sentence are updated.
- No change to `CelPredicateField`, `ConditionBuilder` or
`draftVerdict.ts`. No client copy of any publish rule (#26858), no
`packages/lint`, `packages/spec` or server change.
## Acceptance reading (seat ruling on the step-1 report)
The server judges only a saved draft, and no metadata validate-only door
exists, so the first save of a refused guard goes out: it is the save
whose re-read brings the verdict. Once the verdict shows, the next save
is held and the held line is drawn while the guard still shows the
judged text, a rename of the rule included. An edit of the guard text
itself goes out, to be judged again (#27612's design, `serverHoldAt`).
## Tests
New top-level `describe` in the shared harness
`ui/packages/app-shell/src/views/studio-design/DataPillar.validationVerdictHold-27644.test.tsx`
(real `DataPillar`, a fake door whose draft read refuses `record.amount
> 100` at `validations.N.condition`):
- **(a) the minted rule:** New → "Reject the save when…", guard
`record.amount > 100`, message "Over the cap". The first save goes out
(rule `over_the_cap` at index 2) and the verdict shows. The message edit
renames it to `over_the_cap_now`: the held line names the rule and no
second PUT goes out.
- **(b)** a rename through the name input is held the same way.
- **control:** renaming a rule the verdict does not judge saves.
- **CONTROL** (existing, unchanged): the five #27644 cases and its
control in the same file, and the #27612 / #28027 pins in the nearby
sweep below.
**Ablations** (fix committed first, mutated through
`scripts/ablation-replace.mjs`, restored blob == HEAD `00af991baf66`,
`git diff HEAD` empty):
1. The rename carry removed (the `renameCel` call in `patchRule`
deleted): (a) and (b) red, the control and the #27644 cases green.
2. The in-flight resolution removed (the `renamedTo` walk in `reportCel`
made a no-op): (a) red in 1 of 2 runs, as expected for a timing race.
Before that half was written, the same case was red in 3 of 4 runs.
## Acceptance notes
- **Live, before and after** (fresh showcase, Console Vite over it,
Playwright, my own writable package; the probe and its readings are in
the project files under `issue-27482/live/`). On `main` `58f66b93`: a
rule made through New → "Reject the save when…" saved on every edit
under the red verdict (message, label and guard edits, 4 PUTs, no held
line). The same guard on a rule with an authored name was held. RLS
USING on a formula field was held after the first save, under "Fix the
CEL syntax errors before saving.". After this change: the message edit
that renames the rule and the label edit are held (1 PUT in all, held
line names `qty_too_big_now`), the guard edit goes out, and the RLS held
line reads "Fix the expression errors before saving.".
- **The 11-03 RLS reading "first PUT answers 200"** is the expected
first save above, not a defect: after it, an edit beside the USING was
held live.
## Verification
<details><summary>Tests at the final head c1768bd (main a3ac7fb
merged, no overlap with the touched files)</summary>
- `pnpm --dir ui exec vitest run` over 39 files: every test file naming
`ObjectValidationsPanel`, the Validations tab, `perm.cel.saveBlocked` or
the permission / hooks held lines, plus `studio-namespace.test.ts`,
`draftVerdict.test.ts`, `ConditionBuilder.serverHold-27644.test.tsx` and
`PermissionMatrixEditor.serverVerdictHold-27482.test.tsx` (the #27612 /
#28027 / #27644 / #27629 pins): Test Files 39 passed, Tests 275 passed,
lock VERDICT command-exit 0.
- The harness file alone, 4 consecutive runs before the merge: 9/9 each.
- `turbo run type-check --filter=@object-ui/app-shell
--filter=@object-ui/i18n`: 68/68 tasks, exit 0 (before the merge; the
merge touched no app-shell or i18n file this diff touches).
- `node scripts/check-i18n-en-drift.mjs` (from `ui/`): exit 0, "Every
changed designer-table en value was followed by its zh row."
- `pnpm check:new-line-citations` (from `ui/`): 0 new citations.
</details>
<details><summary>Derived gate union (dispatch-gates --commands): 36 of
36 exit 0</summary>
36 of 36 exit 0 at `c1768bdc`; `dispatch-gates --ran`: 36 derived, 36
run, 0 NOT-MEASURED. `node scripts/check-sdui-manifest.mjs` exit 0.
`pnpm --dir ui exec vitest run scripts/`: 170 files passed, 2 skipped.
`pnpm check:test-source-alias` first asked for module-top preloads of
the lazily loaded `@objectstack/formula`, `@objectstack/lint` and
`@objectstack/spec/identity` in the three edited test files; they were
added (`d2fd8a4c`) and it is green. CI families: read from this PR's
check-runs by the seat.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jSGK8zPYdrSzXgFLDf)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1ebe0c5 commit ba875d2
7 files changed
Lines changed: 120 additions & 5 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views
- metadata-admin
- studio-design
- i18n/src/namespaces/studio
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
185 | 190 | | |
186 | 191 | | |
187 | 192 | | |
188 | | - | |
| 193 | + | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
195 | | - | |
| 200 | + | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
274 | 277 | | |
275 | 278 | | |
276 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
995 | 1002 | | |
996 | | - | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
997 | 1019 | | |
998 | 1020 | | |
999 | 1021 | | |
| |||
1059 | 1081 | | |
1060 | 1082 | | |
1061 | 1083 | | |
| 1084 | + | |
1062 | 1085 | | |
1063 | 1086 | | |
1064 | 1087 | | |
| |||
1069 | 1092 | | |
1070 | 1093 | | |
1071 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
1072 | 1097 | | |
1073 | 1098 | | |
1074 | 1099 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
0 commit comments