Repository navigation
fix(formula)!: validateExpression refuses == / != between a list-valued field and a scalar - #36207
Conversation
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
…rrowing Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
…ect carries no multiple Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
…er list-equality pin Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
… list-equality pin check:test-source-alias: the source reach judged the new test's dynamic imports of @objectstack/formula, @objectstack/lint and @object-ui/core as landing inside a clocked window. Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 6 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 180 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7cdf89ed01e6fb0ed2e775a553ba83f2446b5c6b && git checkout 7cdf89ed01e6fb0ed2e775a553ba83f2446b5c6b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5e8e24302dca5cf4dbda2b97dca4c732c022e7b6 32d1de43e68c8f820fd735aecbfa41a54e364ce5 && git checkout -B drift-repro 5e8e24302dca5cf4dbda2b97dca4c732c022e7b6 && git merge --no-ff 32d1de43e68c8f820fd735aecbfa41a54e364ce5
node scripts/docs-audit/affected-docs.mjs --json 5e8e24302dca5cf4dbda2b97dca4c732c022e7b6
|
…tion's bare names validate_expression reads the list-valued fields off the served definition (servedObjectDefinitionOf), read once and shared with the gate's own passes; a bridge without it answers as before. At a flattened (flow) site a bare name is the trigger record's field, as the type pass reads it, unless a flow variable holds it or the flow's nodes can bind names no reader sees. Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Final green head (area a4-C, validator half of #36167, claim 7068951634; builder half is #36185 in a4-D):
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5 L1 verdict (L1-a): REWORK, bookkeeping only (no code) at head 席位核对Shape and gates.
The code.
R1 (must fix before ACCEPT): the skills-docs follow-up has no card. R2 (must fix: a residual without a carrier). The Acceptance notes record that Next. Both items are a card plus body and changeset edits. If the changeset line moves, that is one docs-only commit, and I will read only that delta and the body. After ACCEPT, the contract-review-tier record is the seat's, and the maintainer lands it. |
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv Contract reviewServed-tier: ① Derived judgments
② Declarations
③ FindingsS1 (should-fix) — False refusal of a correct flow condition. At a flattened site the bare-name branch ( S2 (should-fix) — The Studio as-you-type producer is left out and its named carrier is spent. S3 (should-fix) — A list read through a relationship is not judged and the gap is neither declared nor carried. N1 (nit) — A negative literal ( N2 (nit) — N3 (nit) — ④ Accepted deviations
Implemented-by: VERDICT: FAIL |
At a flattened site the bare-name branch read `record.items.exists(labels, labels == 'a')`'s iteration variable as the list field and refused a per-row condition. The list-equality walk now carries the names the enclosing comprehension macros bind (the engine's own set, COMPREHENSION_MACRO_NAMES) and judges neither a bound bare name nor a member read on a bound root inside the macro's body. The docblock no longer claims the optional spellings reach this pass, and the ADR-0087 entry says which reads are not the shape. Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
…ted at a flow condition Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Final green head, round 3 (L1-a REWORK 7072044449 and contract review FAIL 7072103543; supersedes final-head comment 7072021852):
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5 L1 verdict (L1-a): REWORK, one body line (no code) at head 席位核对R1 closed. The changeset and the body now read R2 closed. The body's residual line for the The review round (contract record 7072103543), read for L1.
R3 (must fix: a residual without a carrier). The body's Acceptance note "A list read through a relationship is not judged (gap, declared)" covers Next. R3, then ACCEPT. After that come the contract reviewer's delta read and the seat's four pieces, and the maintainer lands it. |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv Contract reviewServed-tier: ① Derived judgments
② Declarations
③ FindingsS1 (should-fix): closed S2 (should-fix): closed S3 (should-fix): closed N1 (nit) — unchanged: a negative literal, N2 (nit) — fixed: the docblock at N3 (nit) — unchanged in code; now carried by #36218. ④ Accepted deviations
Implemented-by: VERDICT: PASS |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv 席位核对Awaiting the maintainer's merge (narrowing) · 2026-11-22T03:10Z · head
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv 席位核对Hold, do not enqueue · 2026-11-22T03:47Z · head A later review sweep (#35270, run records r05/r06 on an older head) raised two points about the refusal's prescribed rewrites that the L1 and contract records at this head did not cover. The seat is checking them at this head before landing:
If either holds, a4-C fixes it in a fix round, followed by L1 and contract deltas. |
…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>
… is refused as its bare name is (objectstack-ai#36333) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X8UqWLrzTYpuat8L5eLdf2c)_ Fixes objectstack-ai#34946 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: none — `skills/objectstack-formula/SKILL.md` already states "No date arithmetic. The build refuses `date + n` and `end - start`" and names no site it is limited to, so it now holds for a flow condition's `record.FIELD` / `previous.FIELD` reads as written repo:objectstack#4 · os-project-manager · session_01FEkQ5pb2t8Z8C64PkPyVt1 ## 维护者速读 - 用户能看到什么变化:作者在校验或发布流程时,若流程条件通过「当前记录」或「修改前记录」读取日期字段并直接加减数字,现在会和直接写字段名一样被拒,并提示改用按天计算的函数;以前这种写法能通过校验,运行时却每次失败。 - 为什么做:属于「表达式校验与作者护栏」,替编写流程的管理员和代写流程的 AI 助手解决「校验通过、流程每次运行都出错」的问题,与已修好的日期文本同类问题是同一族。 - 出错会怎样:若误判,作者在校验或发布流程时会看到一条拒绝;已保存的流程照常加载、照常注册,只在下次发布时要求改写;本改动可整体撤回。 - 要你做什么:这是收紧已接受写法的破坏性变更,需要你本人审阅、批准并亲手合并。L1 ACCEPT 7076562103,全量测试 0 失败 7076550688,契约 PASS 7076631700(座位 7,head f278fec);一个不阻塞的遗留写法(main 上同样存在,不是回归)和三个小问题另立 objectstack-ai#36377 跟进。 ## What changes A flow condition (start, edge, `decision` branch) is evaluated over a scope where the run's row is bound twice: its fields flattened to bare names, and the row itself as `record` (with the row before the write as `previous`). The date-arithmetic verdict typed the bare names only. `firstTypeMismatch`'s flattened record-root pass typed `record.FIELD` / `previous.FIELD` but kept only the text/boolean mismatch, so `record.due_date + 1 > 5` passed while `due_date + 1 > 5` was refused, and both fault at run time on the `YYYY-MM-DD` text on every run. Measured through `validateStackExpressions` (the `os validate` body) on a record-triggered flow (`record-after-update`), object `library_loan` with `due_date: date` and `picked_up_at: datetime` (both `required`), start condition: | start condition | before (`origin/main` 28ba01f) | after (this head) | |:---|:---|:---| | `due_date + 1 > 5` | 1 error, date arithmetic `google.protobuf.Timestamp + int`, `due_date` | 1 error (unchanged) | | `record.due_date + 1 > 5` | 0 | 1 error, same verdict, `record.due_date` named | | `previous.due_date + 1 > 5` | 0 | 1 error, same verdict, `previous.due_date` named | | `picked_up_at + 1 > 5` (CONTROL, datetime) | 1 error, `picked_up_at` | 1 error (unchanged) | | `record.picked_up_at + 1 > 5` (CONTROL) | 0 | 1 error, matching the bare name | | `previous.picked_up_at + 1 > 5` (CONTROL) | 0 | 1 error, matching the bare name | | `record.due_date < today()` (CONTROL) | 0 | 0 | | `timestamp(record.due_date) < now()` (CONTROL, date-text) | 1 error, date-text call | 1 error (unchanged, no second finding) | The datetime control: a `datetime` field is a Timestamp in the type check exactly as a `date` field is, and its bare name already took the date-arithmetic verdict, so its root reads now take that verdict too, word for word with the reference swapped. That is the dispatch's control ("keep whatever verdict the bare name gets for a datetime"). - `packages/formula/src/cel-engine.ts`, `firstTypeMismatch`: the record-root pass now answers `category: 'date-arith'` when its first operator fault is date/duration arithmetic against a number (`isDateArith`), with `field` and `root` from `offendingRecordRead(…, 'timestamp')`. The text/boolean branch is unchanged. The comment that said the `date-arith` verdict "stays the bare name's alone" is corrected, and the `root` field's doc and `recordRootReadsFaultDateArith`'s doc say the root read is answered there too. - `packages/formula/src/validate.ts`, `typeSoundnessIssue`: a root read's date verdict takes the row's arm (`dateArm` with `bareNamesUnproven` false), as the root read's type mismatch (objectstack-ai#30025) and date-text verdicts (`recordRootDateTextIssue`) already do. So `record.due_date + 1 > 5` stays `date-arithmetic-run-fails` where bare names are unproven or a flow variable shadows `due_date`. The bare name's arm is unchanged. - No double report: `recordRootDateTextIssue` runs only when `firstTypeMismatch` answers null, and it already stood down on this exact shape (`recordRootReadsFaultDateArith`). The objectstack-ai#34662 date-text pins are green and unchanged. - `packages/spec/src/migrations/entries/semantic/18.flow-condition-record-date-arithmetic-refused.ts`: the ADR-0087 semantic entry (a structured TODO; no mechanical rewrite, since a span in days and a shifted date are different intents), modelled on `18.cel-list-equality-refused.ts`. - `.changeset/34946-flow-record-date-arithmetic.md`: `minor` for `@objectstack/formula` and `@objectstack/spec` (`Metadata-protocol: narrowed` grades `minor`; spec ships the new ADR-0087 entry in its generated migration registry), the declaration lines, the **BREAKING** banner, a FROM to TO table, and `adr-0087: registered flow-condition-record-date-arithmetic-refused`. Reach (the dispatch asked to stop if the narrowing reached beyond flow conditions): the flattened scope is used only by flow conditions. `@objectstack/lint` passes it for start, edge and `decision` conditions, `@objectstack/service-automation`'s `registerFlow` (advisory only) and the MCP `validate_expression` tool's `flow_condition` site. Formula fields, validation rules, hooks and actions are `record`-scoped, where `record.due_date + 1` was already refused (`date-arithmetic`, `-fail-closed`, `-fail-open`). No widening was needed. ## Tests - `packages/formula/src/validate.test.ts`, new top-level describe (objectstack-ai#34946): `record.` and `previous.` date arithmetic refused under `date-arithmetic-run-fails` with full params (`operands`, `reference` naming the read), and the evaluator faults on them over the run's scope. CONTROL: the datetime field's root reads equal the bare name's verdict. Arms: `run-may-fail` with no declared outcome, `run-fails` kept on a root read when bare names are unproven or shadowed. CONTROL: `record.due_date < today()`, `previous.due_date < today()`, `date(record.due_date) < now()` and the prescribed rewrites (`daysBetween(record.due_date, today()) > 5`, `addDays(record.due_date, 1) < today()`, `addDays(previous.due_date, -7) < today()`) are clean. The date-text shapes keep their one finding (`date-text-call-run-fails`, `date-text-arithmetic-run-fails`) and `record.title > 5` keeps `type-mismatch-run-fails`. - `packages/lint/src/validate-expressions.test.ts`, new top-level describe: start, edge and `decision` conditions refuse `record.` / `previous.` at the bare name's path and severity, with the bare name's message and the reference swapped. Reported under `expression-invalid` through `runAuthoringRules('build', …)`, the rule body the runtime publish door runs. CONTROL: datetime root reads equal the bare name's findings at all three sites; `record.due_date < today()` stays clean; `timestamp(record.due_date) < now()` keeps exactly one date-text finding. - `packages/services/service-automation/src/flow-registration-schema-e2e.test.ts`, new top-level describe: `registerFlow` logs the date-arithmetic advisory for `record.` / `previous.` as for the bare name and still registers. CONTROL: an ordering against `today()` is not advised. - `packages/runtime/src/domains/meta-flow-condition-record-date-text.test.ts`, new top-level describe (objectstack-ai#34946, added at `f278fece6f`): the publish door (`publishMetaItem` over the real `ObjectQL` engine) refuses the bare name, `record.due_date` and `previous.due_date` date arithmetic with `INVALID_METADATA` / 422 and one date-arithmetic issue naming the read, leaving the item draft. CONTROL: a datetime field's root reads take the same refusal; `record.due_date < today()` publishes and goes active. The loan fixture gains one required `date` field `due_date`. Runs at `f278fece6f`: 4/4 passed; ablating the cel-engine record-root `isDateArith` branch turns exactly the 2 new tests red, restored to the HEAD blob with `git diff HEAD` empty and `ablation-dist-preflight --absent` clean. Publish door, first measured on head 4426723 as a scratch copy of the same rig (now committed as the pin above): | start condition | publish | date-arithmetic finding | row state | |:---|:---|:---|:---| | `due_date + 1 > 5` | `INVALID_METADATA` / 422 | `expression-invalid`, `due_date` | draft | | `record.due_date + 1 > 5` | `INVALID_METADATA` / 422 | `expression-invalid`, `record.due_date` | draft | | `previous.due_date + 1 > 5` | `INVALID_METADATA` / 422 | `expression-invalid`, `previous.due_date` | draft | | `picked_up_at + 1 > 5` (CONTROL) | `INVALID_METADATA` / 422 | `expression-invalid`, `picked_up_at` | draft | | `record.picked_up_at + 1 > 5` (CONTROL) | `INVALID_METADATA` / 422 | `expression-invalid`, `record.picked_up_at` | draft | | `previous.picked_up_at + 1 > 5` (CONTROL) | `INVALID_METADATA` / 422 | `expression-invalid`, `previous.picked_up_at` | draft | | `record.due_date < today()` (CONTROL) | published | none | active | At `f278fece6f` (the patch round: changeset regrade and the runtime pin): runtime pin 4/4 and its ablation as above; `dispatch-gates --commands` 98 families derived (one more than at 4426723: `check:route-envelope`); the families for the changed paths (`check-adr-0087-registration`, `check-changeset-no-major`, `check-empty-changeset`, `check:cross-package-test-inputs`, `check:test-source-alias`, `check:tier-file-adoption`, `check:route-envelope`) exit 0; `overlap-check` clean. The runs below and the dogfood battery are from 4426723; the patch round changed only the changeset and a runtime test file. <details><summary>Local runs (head 4426723)</summary> All under `scripts/pm/os-verify-lock.sh`, exit codes captured before any pipe: - `pnpm --filter @objectstack/formula build` exit 0; `pnpm --filter @objectstack/formula test` exit 0, Test Files 70 passed (70), Tests 2067 passed (2067); `pnpm --filter @objectstack/formula typecheck` exit 0 (test layer: 7 errors held in `test-typecheck-debt.json`, unchanged). - `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-expressions.test.ts` exit 0, Tests 529 passed (529). - `pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2 src/flow-registration-schema-e2e.test.ts` exit 0, Tests 7 passed (7). - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/migrations` exit 0, Test Files 5 passed (5), Tests 198 passed (198) (spec built with the new entry; `gen:migration-registry` runs in its build). - `node scripts/pm/dispatch-gates.mjs --commands` derived 97 families for this diff; all 97 run locally, reconciled with `--ran`: "97 derived, 97 run, 0 NOT-MEASURED, 0 UNRUN". `pnpm check:dual-build-cjs-loads` first answered PREREQUISITE NOT MET (exit 3, no full build yet), then exit 0 after `check:type-check-debt` built the tree; every other family exit 0 on the first run. - Dogfood battery (the `!` title), on head 4426723: `pnpm --filter @objectstack/dogfood test` under the lock, VERDICT command-exit 0, Test Files 484 passed, 3 skipped (487), Tests 4107 passed, 68 skipped (4175), no failure. - `test:repo` (vitest `repo` project) not run locally: the diff touches none of its tests; it is CI's (`Test Core`). </details> <details><summary>Ablations (each committed first, mutated through scripts/ablation-replace.mjs, restored to the HEAD blob)</summary> 1. Subject: the new `isDateArith` branch of the record-root pass (`packages/formula/src/cel-engine.ts`). Anchor `if (rootTyped && isDateArith(rootTyped)) {` replaced by a never-true guard carrying `ABLATED_34946` (anchor 1 to 0, blob `8eb099d83f32` to `4975d5dd3077`), formula rebuilt, `ablation-dist-preflight.mjs @objectstack/formula ABLATED_34946` exit 0 (the marker reached `dist/`, which the lint and service-automation suites read). Red: formula `validate.test.ts` 3 failed / 236 passed (the three objectstack-ai#34946 verdict tests; the CONTROL for orderings and date-text stayed green), lint 5 failed / 524 passed (all five non-ordering objectstack-ai#34946 tests), service-automation 1 failed / 6 passed (the advisory test). Restored: blob back to `8eb099d83f32` = `HEAD:packages/formula/src/cel-engine.ts`, `git diff HEAD` empty, rebuilt, preflight `--absent` exit 0, lint 529/529 again. 2. Subject: the root read's arm in `typeSoundnessIssue` (`packages/formula/src/validate.ts`). Anchor `dateArm(scope, faultOutcome, mismatch.root !== undefined ? false : bareNamesUnproven)` replaced by `dateArm(scope, faultOutcome, bareNamesUnproven ...)` (blob `aeedf005910e` to `b35d7d64bb2a`). Red: formula `validate.test.ts` 1 failed / 146 passed, the arm test (`record.due_date + 1 > 5` under unproven bare names). Restored: blob `aeedf005910e` = HEAD, `git diff HEAD` empty, 147/147. </details> ## Acceptance notes - Kept as before, deliberately: where bare names are unproven and a source holds both a bare-name date-arithmetic fault and a root-read one (`due_date + 1 > 5 && record.due_date + 1 > 5`), the first (bare) verdict is reported, at `date-arithmetic-run-may-fail`. Still an error; the swap-to-the-root-read step `typeSoundnessIssue` does for a bare type mismatch was not extended to the date verdict. - The field a multi-date expression names is best effort, as for the bare name: `offendingRecordRead` names the first `timestamp` field read through a root, in field-map order. - Declarations follow the two closest precedents in this family (objectstack-ai#34935, objectstack-ai#36207): `Metadata-protocol: narrowed` with a `minor` changeset (regraded at `f278fece6f`). - Carried by objectstack-ai#36377: contract review 7076631700 S1 (a bare date ordering against text AND-ed before a `record.` date arithmetic still passes; measured first on that card) and nits N1–N3. ## Verification Read first, by risk: 1. `packages/formula/src/cel-engine.ts`, the new `isDateArith` branch of `firstTypeMismatch`'s record-root pass (the narrowing itself). 2. `packages/formula/src/validate.ts`, the `dateArm` call in `typeSoundnessIssue` (the root read's arm). 3. `packages/spec/src/migrations/entries/semantic/18.flow-condition-record-date-arithmetic-refused.ts` (the upgrade-guide text). Two-minute check: `pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2 src/validate.test.ts -t 34946` shows 4 passing tests. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pb2t8Z8C64PkPyVt1)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Part of #36167
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #36217
维护者速读
What changes
The shared CEL validator (
validateExpression) now refuses==/!=between a read of a list-valued field onrecord/previous(or, at a flow condition, its bare name) and a non-null string, number or boolean literal, as the new closed codelist-equality. CEL compares the whole list with the scalar, sorecord.labels == 'frontend'answersfalseon every row (and!=answerstrue): the condition never changes, with no fault and no log line.packages/formula/src/validate.ts,checkListEquality/listEqualityRefusal): either operand order; member spellingsrecord.f,record['f'],previous.f. The message names the field and prescribes the null-guarded membership test,record.f != null && "v" in record.ffor==andrecord.f == null || !("v" in record.f)for!=. Params:reference,operator,operand,answer,rewrite. Subjects resolve through a newrootMemberOfhelper inrelationship-traversal.ts, which reuses the existing member-spelling reader.'flattened'site (a flow's start / edge / decision condition) a barelabelsis the trigger record's field, as the type pass already reads it (expression gate: flow-condition type-mismatch verdicts still miss or misdescribe three sites after #29926 (non-record-triggered flows, record.x, decision branches) and MCP validate_expression cannot carry severity or trigger kind #29959 / mcp: validate_expression at flow_condition judges a bare name without the flow's variables, so its type verdict and the door's shadowed-read warning can differ from the runtime flow door #33176 shape), solabels == 'frontend'is refused aslist-equalitynaminglabels. Two exceptions get no verdict: a name a flow variable holds (ExprSchemaHint.flowVariables), and any bare name in a flow whose nodes can bind names no reader sees (bareNamesUnproven).record.labelsis refused in both cases. A name a comprehension macro binds (exists,all,exists_one,map,filter, the engine's ownCOMPREHENSION_MACRO_NAMES) is one item of the list inside that macro's body, sorecord.items.exists(labels, labels == 'a')is not judged there, at any site; the same name outside the macro still is. Measured reading: the docs' canonical spelling isrecord.fand the Studio flow edge writer writesrecord.f, but bare field names are a documented binding, andexamples/writes record-triggered start conditions bare (title != previous.title,status == "completed" && ...).fieldTypesentry of an inherently multi-value type (MULTI_OPTION_TYPES:multiselect,checkboxes,tags), or a field named in the new optionalExprSchemaHint.multiValueFields. Every producer derives that member fromisMultiValueFieldin@objectstack/spec/data; none hand-copies a type list. That is how aselect/radio/lookup/user/file/imagedeclaredmultiple: truebecomes a list. When the member is absent, those types are judged exactly as before.os validate/os build): every CEL site that types the object's fields (predicate sites and formulas), via a per-object index (buildMultiValueFieldIndex).registerFlow's schema pass:parseObjectFieldSchemareturnsmultiValueFields. Logged, never thrown, like every finding of that pass.recordExpressionRefusal).validate_expressiontool, at the validation / formula / flow-condition sites. The list comes off the served definition (McpDataBridge.servedObjectDefinitionOf), which carriesmultiple;describeObject's projection does not. The definition is read once and shared with the gate's own passes (judgeAuthoredSiteExpression), so the reads per call are unchanged. Those passes run withsharedValidatorRunByCaller, so the refusal is not given twice. A bridge without the member answers exactly as before.validateMetadataDraft: field rules, formulas, validation rules), throughCelSchemaHint.multiValueFields.S == null/S != null(either side) and"a" in S.select,user,lookupwithoutmultiple).cel-list-equality-refused(a structured TODO, not a D2 conversion, because the author's intent, membership versus whole-list match, is not recorded). Changeset:minorwith the BREAKING arm, FROM → TO, and a one-line fix.Interpretation, declared. I read "non-null operand" as a non-null scalar literal. A non-literal operand (
record.labels == record.stage), a list literal, or another list subject gets no verdict. Each of these can miss a catch. On the subject side, the pass refuses only a read it can show is the list field: arecord./previous.member read, or a bare name at a flow condition that no declared flow variable and no comprehension macro binds, in a flow whose nodes bind no unseen names. One premise is inherited from the type pass: the MCP tool reads a bare name as the field unless the caller hands it the flow'svariables.Tests
packages/formula/src/validate-list-equality-36167.test.ts(156): first proves the premise on the real engine (["frontend","qa"] == "frontend"is false, and so isnull == "frontend"). Then it covers:record/previous×==/!=× every spelling (dot, reversed, bracket, number, bool, compound);.?/[?], which get onlyinvalid-celagainst a scalar (pinned);select/lookup/userwith and withoutmultiValueFields;select/userdeclared multiple), with controls: record scope, a shadowing flow variable,bareNamesUnproven, the accepted shapes;exists/all/exists_one/filter/mapover a variable named like a list field are accepted (premise on the engine:record.items.exists(labels, labels == 'a')answers per row). The same name outside the macro, an unbound name in the body, andrecord.labelsin the body are still refused.expression-refusal-codes.test.ts:list-equalityis in the closed-code sweep and PINS (code, every param in the message).validate-expressions.list-equality-36167.test.ts(20: actionvisible, a validation rule, a formula, and a record-triggered flow start condition, bare andrecord., with a declared-variable control and two comprehension-variable controls);list-equality-advisory-36167.test.ts(18, including the bare-name premise on the flow engine's ownevaluateCondition:labels == 'frontend'isfalsefor every list and fornull);mcp-validate-expression.list-equality-36167.test.ts(11, through the real stdio bridge: aselect/userdeclaredmultiple: trueis refused once, in the publish gate's sentence read offvalidateStackExpressions; a bridge withoutservedObjectDefinitionOfanswers as before; flow_condition, bare andrecord., with a variable control);scenario-expressions-list-equality-36167.test.ts(4);clientValidation.listEquality-36167.test.ts(7, against the real formula engine).All fixtures go through
ObjectStackSchema.safeParsefirst, where a door takes a stack.Acceptance notes
examples/andpackages/qa, plus hotcrm read-only at 6090c83: a name-based over-approximation of every list-field name compared with a literal.f_lookup, and this PR's own pins.objectstack validateover app-crm, app-showcase, app-todo and app-multi-package reports 0list-equalityfindings, bare-name judging included (re-run at dd76082, each exit 0).multiple: truetocrm_lead.assigned_toplusvisible: record.assigned_to == "u1"makesvalidateexit 1 with "record.assigned_toholds a list". The same predicate withoutmultiple: trueexits 0. Both files were restored byte-identical to HEAD.CelPredicateFieldas-you-type mounts ininspectors/**pass nomultiValueFields(and nofieldTypes), so the editor shows no finding for a list field while the save is refused. Carried by studio: the CEL editor's as-you-type check is given no list fields, so it never flags == / != on a multi-value field that the save then refuses #36219.multiplecatalog card and was not widened here.registerFlow's advisory pass gives the validator noflowVariables. It already types bare names that way. A flow variable that shares a list field's name can therefore draw a logged (never thrown)list-equalityadvisory, as it already can draw a type-mismatch one.os validate, the runtime publish gate and the MCP tool pass the variables. Carried by review follow-ups of PR #36207 #36218 (review follow-ups of PR fix(formula)!: validateExpression refuses == / != between a list-valued field and a scalar #36207).record.account.labels == 'a'validates clean even withtraversalHydration:rootMemberOfanswers only a direct member ofrecord/previous, and the hint carries no hop target's field shapes.ExprSchemaHintholds the subject object'sfields/fieldTypes/multiValueFields,attachedOnRead(names only) andtraversalHydration(a boolean). Judging the hop needs either a new hint member, which is a new producer contract, or a lint pass besiderefuseUndeclaredHopField, which already holds the target definitions. Reported to the seat to file; not widened here. Carried by expression check: == / != on a list field reached through a lookup hop (record.account.labels == 'a') is refused at no door, because the schema hint carries no hop target's field shapes #36237.relationship-traversal.ts: the shared member reader, not a copy of it.narroweddeclaration requires.Verification
First read, by risk:
packages/formula/src/validate.ts—checkListEquality/listEqualityRefusal: what counts as a subject (member read, and the bare name at a flattened site) and an operand. This is the narrowing itself.packages/lint/src/validate-expressions.ts—buildMultiValueFieldIndexand the two sites that pass it, which decide whatos validaterefuses.packages/mcp/src/mcp-http-tools.ts—validate_expression: the subject read moved ahead of the hint and handed togatePassFindings, plusmultiValueFieldsOfServed.Two-minute check:
pnpm --filter @objectstack/formula exec vitest run src/validate-list-equality-36167.test.tsprintsTests 156 passed.Every reading below was taken on this branch. The head is 32d1de4. The second fix round's readings are at that head: the gates, the changed packages' suites, the new ablation and the dogfood battery. Earlier readings are marked with their head.
Dogfood battery (full, no shard, no path) at the final head 32d1de4:
VERDICT command-exit 0; Test Files 484 passed, 3 skipped (487); Tests 4107 passed, 68 skipped (4175). The earlier runs at 82d3bdd, 013e722 and dd76082 gave the same counts.Package suites
At 32d1de4:
src/migrations: 198 passedcelAuthoring*/clientValidation*: 288 passedAt 82d3bdd (first round):
type-checkexit 0Ablation (one per tested behaviour; each leg through ablation-replace, restore proven by blob == HEAD and an empty git diff HEAD)
Second fix round, at 32d1de4:
First fix round, at dd76082:
checkListEquality: 16 failed / 129 passed (145)multiValueFieldshint fill removed: 4 failed / 7 passed (11). The first attempt passed a newline as--replacement; the tool refused it (the replacement count did not rise) and restored, so that reading is void. It was redone with--delete.First round:
validateExpression: 93 failed / 26 passed (119)parseObjectFieldSchemafill removed: 2 failed / 5 passed (7)CelSchemaHintpass-through removed: 3 failed / 4 passed (7)--replacement.Each mutated module is resolved from source by the suite that judged it, so no rebuild leg was needed.
Gates (32d1de4)
node scripts/pm/dispatch-gates.mjs --ran: 105 derived (one more than before:check:swallow-census-controls), 104 run, 1 NOT MEASURED, 0 unrun.check:dual-build-cjs-loadsexit 3, PREREQUISITE NOT MET (packages outside this diff have nodist/). CI runs it.pnpm --dir ui exec vitest run scripts/: in the battery it timed out one case (js-comment-mask-returns-interpolation-9424, a 15 s window, while the dogfood battery shared the box). Re-run alone under the lock: 172 files / 5121 tests, exit 0.pnpm --filter @objectstack/cli exec vitest run test/migrate-meta-engine-guidance.test.ts: exit 99 the first time (lock queue); re-run under the lock, 3/3, exit 0.check:nul-bytesexit 0.overlap-checkagainst origin/main 5e8e243: VERDICT clean.Generated by Claude Code