Repository navigation
fix(formula): label() over a multi-select reads each selected option's label, joined - #34443
Conversation
…els per reader locale Red on main: label(record.<multi-select>) faults and the formula reads null. Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-authored-by: Claude <noreply@anthropic.com>
…joined label(record.<field>) over a multiple: true select faulted on every non-empty selection, so the formula field read null. It now reads the label of each selected value in the reader's locale, in stored order, joined with ', ' — through labelEachOption, the one helper the mail template's option hole prints a multi-select by too. Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-authored-by: Claude <noreply@anthropic.com>
…and en-US; changeset Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-authored-by: Claude <noreply@anthropic.com>
… before label() runs Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check4 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 12 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 4b1aba9f9938d7b82c9994000e88f16305fc3447 && git checkout 4b1aba9f9938d7b82c9994000e88f16305fc3447
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a121e29c280aefb60fdbd48f3f765c5dc8902884 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be && git checkout -B drift-repro a121e29c280aefb60fdbd48f3f765c5dc8902884 && git merge --no-ff 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be
node scripts/docs-audit/affected-docs.mjs --json a121e29c280aefb60fdbd48f3f765c5dc8902884 |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac Final head for review · PR #34443 · 2026-11-16T18:20ZHead-sha: Generated by Claude Code |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn 席位核对 · PR #34443 · L1-b · 2026-11-16T18:23ZHead-sha: 结论:REWORK,一项,只改正文。代码、测试、changeset、docs 按读到的都可以接受。 已核对、无问题
REWORK
备注(不阻塞)
修完后我只读 delta。正文没有 spec 路径,所以不欠 L2。落地前须本 head CI 全绿,按席位的落地路线走。 |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn 席位核对 · PR #34443 · L1-b · delta · 2026-11-16T18:24ZHead-sha: 结论:delta ACCEPT。 R1 已关闭。
L1 未实测: 本 head 的 CI 现为 28 success、14 skipped、31 in progress,无 failure,尚未跑完。 落地条款:须本 head CI 全绿,按席位的落地路线走。本 PR 不触及 spec 路径,不欠 L2。 |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac Landing · PR #34443 · 2026-11-16T18:45Z
State change: ready for review + auto-merge (merge queue). On MERGED, Generated by Claude Code |
Fixes #34339
Clause-②: no
Metadata-protocol: semantic
Skills-docs: follow-up #34444 (
skills/objectstack-formula/SKILL.md, thelabel(record.f)row; the multi-select join is taught in content/docs/data-modeling/formulas.mdx in this PR)维护者速读
label(record.X)作用在多选字段(multiple: true的 select)上,不再出错读成 null,而是按读者语言输出每个已选项的标签,按记录里存储的顺序,用,连接;空选择仍读'',单选不变。label()拼一句「无法估算毛利的原因」,在 18.5.0 上每条记录都读成 null,而os validate/os lint --strict都放行。option占位符走同一个拼接函数,两边不会再分叉。回滚即撤销本 PR。packages/formula/src/stdlib.ts的labelEachOption与optionLabelOf/oneOptionLabel;packages/formula/src/template-engine.ts的option格式化器那一行;packages/objectql/src/engine-formula-option-label.test.ts末尾新增的 describe。pnpm --filter @objectstack/formula exec vitest run src/option-label.test.ts,预期 18 个用例全绿(在 main 上其中 7 个红)。What changes
label(record.FIELD)over amultiple: trueselect used to throw (renders ONE option value, and FIELD holds a list of values), so the formula field read null on every non-empty selection. It now reads:['no_sales_price', 'no_customer']无销售价, 无客户(zh-CN) /No sales price, No customer(en-US)['no_freight_region'][],null''(unchanged; measured below)labelEachOption(packages/formula/src/stdlib.ts, package-internal) maps each listed value through the caller's single-value lookup and joins with,. The mail template'soptionhole (template-engine.ts,OPTION_ARGUMENT_RULE) now calls the same helper instead of its ownmap(...).join(', '), so the two cannot drift. A unit test assertslabel()andformatValue('option', …)print the same string for the same list.['no_freight_region', 'no_sales_price']readsNo freight region, No sales price, although the options declareno_sales_pricefirst. That is the order the template engine already used. This is the claim's choice (claim 6923097287, Shape: "by the same rule the mail-template option hole already uses"), and it differs from the card's words: ask 1 says "joined with,in option order" while naming the mail-templateoptionhole (OPTION_ARGUMENT_RULE) as precedent, and that hole measures STORED order. So a reader of the downstream CRM quote line gets the labels in the order the values were stored, not the order the options are declared.labels()sibling, and no author-time refusal (the card's ask 2): the card asks for it only "Until (1) ships", and ask 1 ships here; claim 6923097287 (Shape) records that choice. Ruling 6919059607 is the claim permission (batch 1), not a ruling on order or on ask 2.formula-option-labels.tsbuilds the label map from every served field that declaresoptions, whatevermultiplesays, with the translation bundle laid over it. The real-engine pin below reads translated multi-select labels through it unchanged.content/docs/data-modeling/formulas.mdxsaid "A multi-value select is refused." It now teaches the join, the order and the empty reading.Tests
packages/formula/src/option-label.test.ts: a new describe for the multi-select (zh-CN and en-US join, one element, stored order, empty list and null, unknown value, composition, a field without options, an object inside the list, and agreement with the mailoptionhole). The old "refuses a list value" assertion is removed. An object value is still refused, in its own case.packages/objectql/src/engine-formula-option-label.test.ts: a new top-level describe on the realObjectQLengine (stub driver, i18n service with a zh-CN bundle) readslabel(record.gaps)over a multi-select in zh-CN and en-US, beside a single-select CONTROL on the same record, plus the one-element and empty cases.packages/qa/dogfood/test/formula-option-label-locale.dogfood.test.ts: the fixture gains a multi-select and its formula. One new case reads it through REST (POST/GET /data/:object/:idwithAccept-Language) in zh-CN and en-US, with the existing single-select name as the CONTROL, plus the one-element, empty-list and unset cases.Acceptance notes
mainis red oncheck:platform-checklist(approvals.approver-resolution-matrixVARIANTS STALE). That red is main's, not this diff's; the seat has a stopgap PR.Lint & Repo Gateswill show it on this PR.record.gapson{}) faults withNo such keybeforelabel()runs. This is the same for a single select and is not changed here. The engine hands formulas every declared field, so a stored record does not hit it.Verification
All readings below come from runs under
scripts/pm/os-verify-lock.sh, on a shared box.4a1ed6a82f: the dogfood file alone, afterturbo run build --filter='@objectstack/dogfood^...'(70 tasks, exit 0):pnpm --filter @objectstack/dogfood exec vitest run --maxWorkers=1 test/formula-option-label-locale.dogfood.test.tsgivesTest Files 1 passed (1),Tests 6 passed (6)(5 existing + the new multi-select case). Lock VERDICTcommand-exit 0. Its red on main was not run; the objectql pin carries the red-on-main reading.Red on main (tests at c0547aa, formula source at the merge base)
pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2 src/option-label.test.ts:Tests 7 failed | 11 passed (18). Each of the seven multi-select cases answered{ ok: false, … }.pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-formula-option-label.test.ts:Tests 2 failed | 10 passed (12),AssertionError: expected null to be '无销售价, 无客户'. The engine logged the card's own line:formula field 'gaps_note' on 'ol_quote_line' could not be evaluated, so it reads null … label(record.gaps) renders ONE option value, and gaps holds a list of values on this record.''for[]and fornullthere, and still does.Green, and the ablation (one locked run at 6fa079a; formula src unchanged since)
pnpm --filter @objectstack/formula build: exit 0.node scripts/ablation-dist-preflight.mjs @objectstack/formula 'oneOptionLabel(field, item, options, true)': marker present indist/index.jsanddist/index.mjs.Tests 12 passed (12).pnpm --filter @objectstack/formula typecheck: exit 0.node scripts/ablation-replace.mjs --file packages/formula/src/stdlib.ts --anchor ' if (Array.isArray(value)) return labelEachOption(…);' --delete -- …. Anchor count went from 1 to 0, blobaf2083df5155toa999c7ce79c1. Formula rebuilt,--absentpreflight: marker absent from all 6 built files. Then objectql fileTests 2 failed | 10 passed (12)and formula fileTests 7 failed | 11 passed (18). Restore:blob == HEAD (af2083df5155) and git diff HEAD is empty. Rebuilt, marker present again, objectql fileTests 12 passed (12).option-label.test.ts:pnpm --filter @objectstack/formula testgivesTest Files 67 passed (67),Tests 1770 passed (1770).Derived gates
At the final head
4a1ed6a82f:node scripts/pm/dispatch-gates.mjs --commandsderived 94 commands, and all 94 were run locally, each exit code captured before any pipe: 94 exit 0.node scripts/pm/dispatch-gates.mjs --rangives:94 derived famil(ies) accounted for — 94 run, 0 NOT-MEASURED (a DERIVED zero — all 94 recorded an exit code and none of them is 3). CI'sLint & Repo Gatesruns the full farm.!in the title, no(narrowing)arm).Generated by Claude Code