Repository navigation
fix(studio): the CEL condition builder offers membership, not equals, on a list field - #36185
Conversation
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1 Co-authored-by: Claude <noreply@anthropic.com>
…tions pin Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1 Final green head · area a4-D · 2026-11-21T20:58Z |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5oVqoTJkrRZcyZS4xd 席位核对 — REWORK (PR body only) · head ef21bbcNo code change is asked for. The code, pins, text and gates hold, as listed below. Two sentences in the PR body are no longer true, and one of them is a residual noted with no carrier. To fix (body edit; the head stays ef21bbc)
A body edit re-runs the PR-body guards. Tell me when they are green, and I will read the body alone. Checked and holding
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5oVqoTJkrRZcyZS4xd 席位核对 — ACCEPT (body) · head ef21bbcI read the body alone, after REWORK 7069188201. The head is unchanged, so everything checked in that record stands.
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1 席位核对Landing · area a4-D · 2026-11-21T23:17Z · head
Ready + auto-merge now. |
…ite, and judges a flow condition only where the run binds the typed row (objectstack-ai#36340) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbPgGMxS6cCEEprR4e3dQNe9)_ Fixes objectstack-ai#36167 This is the card's last item: the builder half (objectstack-ai#36185) and the validator half (objectstack-ai#36207) are merged, and the remaining follow-ups have their own cards (objectstack-ai#36217 skills text, objectstack-ai#36218 review follow-ups, objectstack-ai#36219 the as-you-type editor). Clause-②: yes (widening) Metadata-protocol: added Skills-docs: follow-up objectstack-ai#36217 ## 维护者速读 - 作者把多值字段(多选、多人等)与单个值比较相等时,系统给出的改写建议现在在每个位置都能用:共享规则条件里也能用,且建议本身加了括号,不会被前面的条件拆开;由接口、定时或无触发方式启动的流程里,这种写法不再被误拒。 - 属于「表达式校验与作者护栏」:上一个已合并的拉取请求开始拒绝这种写法,复审发现它给的改写在共享规则里无法生效、部分写法会报错,还会误拒正确的流程条件。 - 若出错,作者看到的只是另一种改写建议,或某个流程条件不再被拦下;本改动可以整体撤回,不影响已存储的数据。 - 无 ## What changes Follow-up to objectstack-ai#36207, which merged before its round-4 review findings were addressed. This PR covers four of them: r05 S1, r05 S2, r05 S4 / r06 N1, and r06 S1. **The prescribed rewrite is spelled for its site and parenthesised whole** (`listMembershipRewrite` in `packages/formula/src/validate.ts`). Each spelling below was measured on the site's own evaluator or filter compiler: | site | `==` rewrite | `!=` rewrite | |---|---|---| | a `record.` / `previous.` read evaluated as CEL (validation rule, field rule, formula, action `visible` / `disabled` / `pressed`, hook condition) | `(has(record.f) && record.f != null && "v" in record.f)` | `(!has(record.f) \|\| record.f == null \|\| !("v" in record.f))` | | a bare name at a flow condition (the run binds every declared field, `null` when empty) | `(f != null && "v" in f)` | `(f == null \|\| !("v" in f))` | | a sharing rule `condition`, compiled to a query filter (new `ExprSchemaHint.filterCompiled`, filled by the publish lint) | `(record.f != null && record.f.contains("v"))` | `(record.f == null \|\| !record.f.contains("v"))` | No single spelling works at every site, which is why the rewrite differs per site: - `"v" in record.f` does not lower to a filter. `compileCelToFilter` answers "`in` requires a field on the left (got literal)", so the sharing rule is dropped as `sharing-rule-unlowerable-condition`. - `has()` does not lower either ("unsupported operator call"). - On the CEL evaluator, `record.f.contains("v")` faults on a list, because there is no `list.contains` overload. - `record.f != null && "v" in record.f` faults on a row that lacks the key ("No such key"), which a sparse action row does. It also faults on a null `previous`, as on a create. The filter spelling lowers to `$and[{f:{$null:false}}, {f:{$contains:"v"}}]` and `$or[{f:{$null:true}}, {$not:{f:{$contains:"v"}}}]`. `$contains` on a JSON-stored (multi-value) column is membership in `matchesFilterCondition` and in driver-sql (`sql-driver-17590-json-column-membership.test.ts`). A number or boolean operand is passed as its text (`contains("3")`), since `$contains` compares text. The sharing-site message also says why `==` does not work there: the query filter refuses `$eq` against a list column. **A flattened (flow) site is judged only where the run binds a row of the typed object** (r06 S1). `checkListEquality` now returns early at a `'flattened'` site unless `faultOutcome` is `'run-fails'`. That outcome is declared only on a record-triggered flow, or on a time-relative sweep of the typed object: the lint's `faultOutcomeOf` ledger, `validate-expressions.ts` around line 1632. On any other flow (API, schedule, no trigger), the ledger's own row says the run "holds what its entrance handed it". `seedRunVariables` flattens whatever record that is. So an API flow whose request body carries a string `labels` runs `labels == 'frontend'` correctly, and objectstack-ai#36207 refused it. The MCP tool already passes this outcome for `flow_condition` (its default `triggerKind` is `record_change`). `registerFlow`'s advisory pass now passes it on the same flows (`runBindsTypedRow`, which this PR moves above the hint). Side effect: on those flows, the pass's logged type-mismatch lines take the `run-fails` wording that `os validate` already prints. It still only logs and never throws. **Docblocks (r05 S4 / r06 N1).** - `ExprSchemaHint.multiValueFields` now names the forms actually judged: - `record.f` / `previous.f` and the bracket spelling; - the optional spellings, which are refused as `invalid-cel` first; - the bare name, only at a flattened site with `run-fails`, excluding `flowVariables` and `bareNamesUnproven`; - comprehension-bound names, which are never the field. - `ExpressionRefusalParams['list-equality']` now documents `reference` (the bracket spelling renders `record.f`; a bare name is the bare name) and the per-site `rewrite`. **Semantic entry** `cel-list-equality-refused` now has the per-site replacement text and the narrowed surface. The surface adds the sharing rule condition and limits flows to the proven-row ones. ## Tests - `packages/formula/src/validate-list-equality-36167.test.ts` - New describe, "the prescribed rewrite tests membership where it is read". For each site class it takes the rewrite out of the refusal itself, pins its text, and runs it: - **CEL member read:** evaluated on rows `[a,b]` / `[b]` / `[]` / `null` / absent, and with `previous = null`. Each is also checked inside `record.name == 'x' && …`, `record.name == 'y' && …` and `false || …`, which pins the parenthesisation. - **Bare name:** evaluated with the row bound as top-level names. - **Filter:** lowered with `compileCelToFilter` and matched with `matchesFilterCondition` (with the column declared `tags`), including inside `&&`. - Each rewrite validates clean at its own site. - The CEL `in` form is shown not to lower. - New describe, "a flattened site with no proven row binding gets no verdict": bare and `record.` reads, `fail-closed` / `fail-open`, plus a proven-site control. - `packages/formula/src/expression-refusal-codes.test.ts`: the two `list-equality` PINS carry the new rewrites. Two new pins cover the bare name at a proven flattened site and the `filterCompiled` site, with params and the whole message. - `packages/lint/src/validate-expressions.list-equality-36167.test.ts`: - action `visible` rewrites pinned, and each validates clean; - a flow condition's bare `!=` rewrite pinned in the parenthesised form and accepted inside `stage == 'qa' && …`; - CONTROLS: an API, a trigger-less autolaunched and a scheduled flow get no list-equality, bare or `record.`; - new describe, the sharing rule `condition`: refused with the `contains` rewrite, and that rewrite draws no finding from the expression lint or from `validateSharingRuleEnforceability` (it lowers); - CONTROL: the CEL `in` forms draw `sharing-rule-unlowerable-condition` there. - `packages/services/service-automation/src/list-equality-advisory-36167.test.ts`: - `makeFlow` now states its trigger (`record-after-update`); - parenthesised bare rewrite pinned and not reported itself; - CONTROLS: API, scheduled and trigger-less flows report nothing; - premise: the bare rewrites answer per row on `evaluateCondition`, including `false && (…)`. - Two fixtures fixed at `254d40cb` (they had never run; each stopped before the behaviour it pins): - the sharing-rule describe in the lint pin built its rule with a recipient type the spec does not have (`role`) and no rule `type`, so all three cases failed at the spec-validity guard. It now uses `type: 'criteria'` and a `team` recipient, as the other spec-valid sharing fixtures do; - the API-flow CONTROL in the service-automation pin carried no hook secret, so `registerFlow` refused the flow before the advisory pass ran. It now names a `secretRef` (ADR-0041). - `packages/mcp/src/mcp-validate-expression.list-equality-36167.test.ts`: the `flow_condition` rewrite is pinned and validates clean. CONTROL: `triggerKind` `api` / `schedule` / `none` get no list-equality. ## Acceptance notes - **Clause ② for this diff: `yes (widening)`.** Two things widen: - it adds the optional public key `ExprSchemaHint.filterCompiled`; - flow conditions on API / scheduled / trigger-less flows are accepted again, after objectstack-ai#36207 refused them. Nothing in this diff refuses more. The changed rewrite text and the narrower flattened scope are not narrowings. `Metadata-protocol: added` because an accepted value is restored, so every package moved is `minor`. - The driver-sql leg of the filter rewrite is cited, not run here: `$contains` membership on a JSON column is pinned in `sql-driver-17590-json-column-membership.test.ts`, and `$not` is NULL-safe (objectstack-ai#5146). This PR measures the lowering and `matchesFilterCondition`. - Decision node `config.condition` in the lint: only the start node's gate and edge / branch conditions carry the flow's outcome. An inert node condition already has its own `flow-inert-node-condition` finding, and gets no list-equality verdict. - L2 S1 carried by objectstack-ai#36218 (scope !== 'record'); nits N1–N4 accepted. ## Verification Final head `254d40cb` (handover head `5a29954a` + `origin/main` merged at `2b570445` + the two fixture fixes). Every reading below is at that head. <details><summary>Package suites and pins</summary> - Build closure `--filter '@objectstack/lint^...' --filter '@objectstack/mcp^...' --filter '@objectstack/service-automation^...' --filter '@objectstack/scenarios^...' build`: lock VERDICT command-exit 0. Later a full `pnpm build --concurrency=2`: 120/120 tasks, VERDICT command-exit 0. - Pins: formula `validate-list-equality-36167` + `expression-refusal-codes` 250/250 (the 8 bare-name failures of the handover run are gone); lint `validate-expressions.list-equality-36167` 27/27 (3 failed before the fixture fix); mcp `mcp-validate-expression.list-equality-36167` 15/15; service-automation `list-equality-advisory-36167` 22/22 (1 failed before the fixture fix). - Full suites, one locked run, VERDICT command-exit 0: formula build + test 70 files / 2107 tests + typecheck exit 0; lint 225 files / 9434 tests + typecheck exit 0; mcp 83 files / 1467 tests + typecheck exit 0; service-automation 290 files / 4220 tests + typecheck exit 0; spec `src/migrations` 5 files / 198 tests. </details> <details><summary>Ablations (seven, each through ablation-replace WRAP mode under the lock)</summary> Each mutation was proven on disk (anchor 1 to 0, blob changed) and restored (blob equal to the HEAD blob, empty `git diff HEAD`). Every mutated module is read from source by its suite, so there is no dist leg. | ablation | file | pin result | |---|---|---| | delete the flattened proven-row early return | formula `validate.ts` | 5 failed / 245 passed (250) | | never take the `filterCompiled` spelling | formula `validate.ts` | 13 failed / 237 | | drop the outer parentheses of the `!=` member-read rewrite | formula `validate.ts` | 6 failed / 244 | | drop `has()` from the `==` member-read rewrite | formula `validate.ts` | 4 failed / 246 | | lint passes no `filterCompiled` at the sharing rule | lint `validate-expressions.ts` | 2 failed / 25 (27) | | service-automation always declares `run-fails` | `flow-registration-checks.ts` | 3 failed / 19 (22): the API, scheduled and trigger-less CONTROLS | | service-automation never declares `run-fails` | `flow-registration-checks.ts` | 5 failed / 17 (22) | </details> <details><summary>Derived gates</summary> - `dispatch-gates --commands` at `254d40cb`: 96 families. `dispatch-gates --ran` with recorded exit codes: 96 derived, 96 run, 0 NOT-MEASURED (a derived zero), every family exit 0. - Three needed a prerequisite first and were re-run: `check-plugin-teardown-shape --self-test` (exit 3 on the shallow clone until its pinned fixture commit was fetched, then exit 0); the cli `migrate-meta-engine-guidance` vitest (exit 1, MODULE_NOT_FOUND on an unbuilt `@objectstack/mcp` dist, then 3/3 after the full build); `check:dual-build-cjs-loads` (exit 3 PREREQUISITE NOT MET, then exit 0 after the full build: 124 require entry points across 72 packages load). - `check:type-check-debt` exit 0. `check:nul-bytes` OK. `overlap-check` VERDICT clean exit 0 against `origin/main` `2b570445` and objectstack-ai#36333 (shares `validate.ts`, merges cleanly). - CI at `254d40cb`: all 69 check-runs completed, every one success or skipped (Check Changeset, PR-body guards, Governed Surface Queue Guard, every Lint and Type Check lane, Test Core 10/10 shards, Test UI 16/16, Build Core, Dogfood Regression Gate). - `test:repo` was not run locally (the diff touches no repo-project test); CI's Test Core ran it. </details> Dogfood battery: n/a (no `!` in the title, and `Clause-②: yes (widening)` has no `(narrowing)` arm). Two-minute check: `pnpm --filter @objectstack/formula exec vitest run src/validate-list-equality-36167.test.ts`. Expected: every test passes, including the "prescribed rewrite" and "no proven row" describes. Read first, by risk: 1. `packages/formula/src/validate.ts`: `listMembershipRewrite` and the early return in `checkListEquality`. 2. `packages/services/service-automation/src/flow-registration-checks.ts`: `faultOutcome` on the advisory hint. 3. `packages/lint/src/validate-expressions.ts`: the sharing-rule `check(…, true)`. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jVXKcrF3rr7ShYFZ9E <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jVXKcrF3rr7ShYFZ9E --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Leehom · project thread
Part of #36167 — the builder half. The card's Done-when also names
validateExpressionrefusing a list compared with a scalar; that half narrows an accept set and is not built here: the seat picked option A on the card (7068927390), and area a4-C claimed it (7068951634) under its ownPart of #36167.Clause-②: no
Metadata-protocol: none
维护者速读
What changes
ConditionBuilder(the Studio CEL condition builder behind hook, validation-rule, action visibility, page-block and flow entry conditions) now offers a list subject (amultiselect/checkboxes/tags, or aselect/lookup/userdeclaredmultiple: true) exactly what the shared filter builder offers it: contains, does not contain, is empty, is not empty.==/!=/ ordering are no longer offered there. Which operators a list takes is read fromjsonColumnFilterOperators(through the newlistSubjectOperators), not restated; a small table only translates those names onto the builder's own operator values.S != null && V in S, does not contain writesS == null || !(V in S). That is the spelling the flow edge's rows shipped; it now lives in one module,inspectors/cel-list-membership.ts(listMembershipCel/readListMembership/listSubjectOperators), andflow-edge-condition-rows.tswrites through it too (its output is byte-for-byte unchanged; its existing pins hold).equalsforcontains; moved off a list, membership becomesequals. An operator offered on both sides (is empty / is not empty) stays, re-spelled for the new field.record.labels == 'frontend'on a list, or membership on a single-value field) opens in the raw expression editor exactly as stored: never rewritten, nothing emitted.engine.inspector.condition.op.notContains(en, zh).Tests
ConditionBuilder.listSubject-36167.test.tsx(27 tests): each of six list subjects offers the shared builder's list set and nothing else; three single-value controls keep equals / not equals and get no membership; the written CEL equals what the flow edge'srowsToCelwrites for the same row and is evaluated bycelEngine(member true, non-member false,[]andnullnull-safe both ways); stored membership round-trips; stored==/!=on a list and membership on a single-value field open raw and verbatim; an instrument control shows the replaced==answering a constant.ConditionBuilder.typedEmptyOps-11894, two cases;ObjectValidationsPanel.typedEmptyOps-11894, one case) seeded a list subject's row asS == 'x'only to reach its operator dropdown. That seed now opens in the raw editor, so it became the membership row; what each case pins (the empty check on a list, and thatmultiplereaches the builder) is unchanged and still needs the flag to reach the builder.Acceptance notes
celEngine(objectstack tree at this branch):'a' in SwithS = nullfaults (no such overload forstring ina null dyn), withS = []answers false;S == 'a'is false for['a','b']and fornull;S.contains('a')faults on a list. Hence the null guard on both membership spellings.S == null/S != nullon a list subject also opens raw now (the builder's own spelling for it is is empty / is not empty). Unchanged bytes, by the round-trip rule.ResourceEditPage's object fetch) droppedmultipleon this branch's base. fix(ui): the view / page-block filter editor offers a multiple: true field membership only #36182 (merged tomainas 865df27) closes it: the fetch now goes throughobjectCatalogOf, which carriesmultiple: true, and the condition widget hands that catalog toConditionBuilderunprojected, so after this PR lands aselect/lookup/userdeclaredmultiple: trueis a list subject at that mount too.multiselect/checkboxes/tagsare lists by type alone. The hook, page-block, action, flow-entry and validation-panel mounts carrymultiple.node scripts/pm/overlap-check.mjsreports a textual overlap with draft PR feat(spec): relatedLists is the record page's tab list, with built-in tabs by object name and per-entry title and columns #35923 on the studio en / zh catalogues (different keys). Not merged around.Verification
Read first (risk order):
ui/packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.tsx:initFrom(the new offered-operator check that sends a stored row to the raw editor) andwithOfferedOpon a subject change.ui/packages/app-shell/src/views/metadata-admin/inspectors/cel-list-membership.ts: the shared spelling and reader.ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-edge-condition-rows.ts: now writes through the shared module.Two-minute check:
pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.listSubject-36167.test.tsx— expect 27 passed.Local readings at
ef21bbcb31(objectstack tree):Tests, type-check, ablation
ConditionBuilder.listSubject-36167.test.tsx: 27 passed. Allinspectors/ConditionBuilder*,flow-edge-condition-rows*,FlowEdgeInspector*suites: 22 files, 262 tests passed (two locked runs; five suites first failed to collect on an unbuilt@objectstack/client, passed once it was built).ObjectValidationsPanel*,FlowNodeConfigField*,HookDefaultInspector*,ActionDefaultInspector*,PageBlockInspector.visibleWhen*,FlowNodeInspector.entryCondition*,widgets*ondition*): 33 files, 323 passed, 1 failed before triage (theObjectValidationsPanel.typedEmptyOps-11894list seed); after triage that file passes, run withpackages/i18n/(106 files, 1967 passed) and withui/scripts/(175 files, 5126 passed).pnpm --filter @object-ui/app-shell type-checkandpnpm --filter @object-ui/i18n type-check: exit 0 (lock VERDICT command-exit 0).opChoicesForthroughscripts/ablation-replace.mjs(anchor 1 to 0) turns the new pin 19 failed / 8 passed of 27; the 8 are the single-value controls, the instrument control and the raw-open cases.Gates
node scripts/pm/dispatch-gates.mjs --commands(diff-derived, 38 families) all exit 0 atef21bbcb31;--ranreconciliation: 38 derived, 38 run, 0 NOT-MEASURED (a derived zero).pnpm --dir ui check:new-line-citations: 0 new. ESLint on the changed files: 0 errors (warnings pre-existing). CI runs the full farm.Generated by Claude Code